Android app crashed if the main activity isn't MainActivity -
i want start loading view crashed when open if main activity in androidmanifiest.xml isn't mainactivity. on emulator fine problem when install apk in phone. help?
androidmanifiest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.daniel.jaentodayapp"> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity" android:screenorientation="portrait" android:theme="@style/apptheme.noactionbar"> </activity> <activity android:name=".loadingscreen" android:screenorientation="portrait" android:theme="@style/apptheme.noactionbar"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application>
loadingscreen
public class loadingscreen extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_loading_screen); new thread(new runnable() { public void run() { try { thread.sleep(3000); } catch (interruptedexception e) { e.printstacktrace(); } { intent intent = new intent(loadingscreen.this, mainactivity.class); startactivity(intent); } } }).start(); } @override protected void onpause() { super.onpause(); finish(); }}
layout loading screen
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_loading_screen" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.daniel.jaentodayapp.loadingscreen"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/pcarga"></linearlayout></relativelayout>
this error:
e/androidruntime: fatal exception: main process: com.example.daniel.jaentodayapp, pid: 18967 java.lang.runtimeexception: unable start activity componentinfo{com.example.daniel.jaentodayapp/com.example.daniel.jaentodayapp.loadingscreen}: android.view.inflateexception: binary xml file line #9: binary xml file line #9: error inflating class <unknown> @ android.app.activitythread.performlaunchactivity(activitythread.java:2416) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.access$900(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: android.view.inflateexception: binary xml file line #9: binary xml file line #9: error inflating class <unknown> @ android.view.layoutinflater.inflate(layoutinflater.java:539) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ android.support.v7.app.appcompatdelegateimplv9.setcontentview(appcompatdelegateimplv9.java:284) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:140) @ com.example.daniel.jaentodayapp.loadingscreen.oncreate(loadingscreen.java:13) @ android.app.activity.performcreate(activity.java:6285) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.access$900(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: android.view.inflateexception: binary xml file line #9: error inflating class <unknown> @ android.view.layoutinflater.createview(layoutinflater.java:645) @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58) @ android.view.layoutinflater.oncreateview(layoutinflater.java:694) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) @ android.view.layoutinflater.rinflate(layoutinflater.java:835) @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798) @ android.view.layoutinflater.inflate(layoutinflater.java:515) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ android.support.v7.app.appcompatdelegateimplv9.setcontentview(appcompatdelegateimplv9.java:284) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:140) @ com.example.daniel.jaentodayapp.loadingscreen.oncreate(loadingscreen.java:13) @ android.app.activity.performcreate(activity.java:6285) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.access$900(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: java.lang.reflect.invocationtargetexception @ java.lang.reflect.constructor.newinstance(native method) @ android.view.layoutinflater.createview(layoutinflater.java:619) @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58) @ android.view.layoutinflater.oncreateview(layoutinflater.java:694) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) @ android.view.layoutinflater.rinflate(layoutinflater.java:835) @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798) @ android.view.layoutinflater.inflate(layoutinflater.java:515) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ android.support.v7.app.appcompatdelegateimplv9.setcontentview(appcompatdelegateimplv9.java:284) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:140) @ com.example.daniel.jaentodayapp.loadingscreen.oncreate(loadingscreen.java:13) @ android.app.activity.performcreate(activity.java:6285) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.access$900(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: java.lang.outofmemoryerror: failed allocate 255322380 byte allocation 12571568 free bytes , 126mb until oom @ dalvik.system.vmruntime.newnonmovablearray(native method) @ android.graphics.bitmapfactory.nativedecodeasset(native method) @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:609) @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:444) @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:1080) @ android.content.res.resources.loaddrawableforcookie(resources.java:2635) @ android.content.res.resources.loaddrawable(resources.java:2540) @ android.content.res.typedarray.getdrawable(typedarray.java:870) @ android.view.view.<init>(view.java:3955) @ android.view.viewgroup.<init>(viewgroup.java:574) @ android.widget.linearlayout.<init>(linearlayout.java:203) @ android.widget.linearlayout.<init>(linearlayout.java:199) @ android.widget.linearlayout.<init>(linearlayout.java:195) @ java.lang.reflect.constructor.newinstance(native method) @ android.view.layoutinflater.createview(layoutinflater.java:619) @ com.android.internal.policy.phonelayoutinflater.oncreateview(phonelayoutinflater.java:58) @ android.view.layoutinflater.oncreateview(layoutinflater.java:694) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:762) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) @ android.view.layoutinflater.rinflate(layoutinflater.java:835) @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798) @ android.view.layoutinflater.inflate(layoutinflater.java:515) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ android.support.v7.app.appcompatdelegateimplv9.setcontentview(appcompatdelegateimplv9.java:284) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:140) @ com.example.daniel.jaentodayapp.loadingscreen.oncreate(loadingscreen.java:13) @ android.app.activity.performcreate(activity.java:6285) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1108) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.access$900(activitythread.java:150) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method)
you can call startactivity()
main thread. if want make call runnable
use handler
if call .run()
instead of .start()
runnable executed on calling thread
Comments
Post a Comment