java - App stopps working -
this question has answer here:
i cant figure out doing wrong. i'm complete beginner in coding dont mad :)
basically wanted animated background in splash screen. app stopps working every time launch it.
heres code , error:
welcome activity (splash):
public class welcomeactivity extends appcompatactivity { private static int splash_time_out = 4000; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_welcome); android.support.v7.app.actionbar actionbar = getsupportactionbar(); actionbar.hide(); imageview bgani = (imageview) findviewbyid(r.id.imagebg); bgani.setbackgroundresource(r.drawable.animation_list); animationdrawable pro = (animationdrawable) bgani.getbackground(); pro.start(); new handler().postdelayed(new runnable() { @override public void run() { intent welcomeintent = new intent(welcomeactivity.this, mainactivity.class); startactivity(welcomeintent); finish(); } }, splash_time_out); } }
main activity:
public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } }
welcome xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="de.procre.togetheraware.welcomeactivity"> <imageview android:id="@+id/imagebg" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/animation_list" android:scaletype="fitxy"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello world!" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:textcolor="@color/pure_white"/> </relativelayout>
animation list:
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/anim_background" android:oneshot="true"> <item android:drawable="@drawable/frame0000" android:duration="30" /> <item android:drawable="@drawable/frame0001" android:duration="30" /> . . . <item android:drawable="@drawable/frame0124" android:duration="30" /> </animation-list>
error code:
08-18 12:45:41.171 13517-13517/de.procre.togetheraware e/androidruntime: fatal exception: main process: de.procre.togetheraware, pid: 13517 java.lang.outofmemoryerror: failed allocate 6350412 byte allocation 4120384 free bytes , 3mb until oom @ dalvik.system.vmruntime.newnonmovablearray(native method) @ android.graphics.bitmapfactory.nativedecodeasset(native method) @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:620) @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:455) @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:1155) @ android.content.res.resourcesimpl.loaddrawableforcookie(resourcesimpl.java:720) @ android.content.res.resourcesimpl.loaddrawable(resourcesimpl.java:571) @ android.content.res.resources.loaddrawable(resources.java:854) @ android.content.res.typedarray.getdrawable(typedarray.java:928) @ android.graphics.drawable.animationdrawable.inflatechildelements(animationdrawable.java:327) @ android.graphics.drawable.animationdrawable.inflate(animationdrawable.java:297) @ android.graphics.drawable.drawableinflater.inflatefromxml(drawableinflater.java:130) @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:1227) @ android.graphics.drawable.drawable.createfromxml(drawable.java:1200) @ android.content.res.resourcesimpl.loaddrawableforcookie(resourcesimpl.java:715) @ android.content.res.resourcesimpl.loaddrawable(resourcesimpl.java:571) @ android.content.res.resources.loaddrawable(resources.java:854) @ android.content.res.typedarray.getdrawable(typedarray.java:928) @ android.widget.imageview.<init>(imageview.java:157) @ android.widget.imageview.<init>(imageview.java:145) @ android.support.v7.widget.appcompatimageview.<init>(appcompatimageview.java:60) @ android.support.v7.widget.appcompatimageview.<init>(appcompatimageview.java:56) @ android.support.v7.app.appcompatviewinflater.createview(appcompatviewinflater.java:106) @ android.support.v7.app.appcompatdelegateimplv9.createview(appcompatdelegateimplv9.java:1026) @ android.support.v7.app.appcompatdelegateimplv9.oncreateview(appcompatdelegateimplv9.java:1083) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:769) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:727) @ android.view.layoutinflater.rinflate(layoutinflater.java:858) @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:821) @ android.view.layoutinflater.inflate(layoutinflater.java:518) @ android.view.layoutinflater.inflate(layoutinflater.java:426) @ android.view.layoutinflater.inflate(layoutinflater.java:377) @ android.support.v7.app.appcompatdelegateimplv9.setcontentview(appcompatdelegateimplv9.java:289) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:139) @ de.procre.togetheraware.welcomeactivity.oncreate(welcomeactivity.java:22) @ android.app.activity.performcreate(activity.java:6662) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1118) @ android.app.activitythread.performlaunchactivity(activitythread.java:2599) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2707) @ android.app.activitythread.-wrap12(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1460) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:154) @ android.app.activitythread.main(activitythread.java:6077) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:866) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:756)
try these make make android:hardwareaccelerated="false"
, android:largeheap="true"
in application tag of manifiest file this
<application android:largeheap="true" android:hardwareaccelerated="false">
Comments
Post a Comment