android - ANR while starting new activity -
hi i'm displaying screen 3 seconds , i'm starting new activity on android 5.0 there black screen 10 sec , anr. code activity displaying 3 seconds:
private static final scheduledexecutorservice worker = executors.newsinglethreadscheduledexecutor(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); crashlytics.start(this); setcontentview(r.layout.splash_fragment); runnable task = new runnable() { public void run() { startactivity(new intent(splashactivity.this, mainactivity.class)); finish(); } }; worker.schedule(task, 3, timeunit.seconds); }
and logs logcat:
activity destroy timeout activityrecord i/inputdispatcher( 725): application not responding: appwindowtoken has been 5005.0ms since event, 5003.6ms since wait started. reason: waiting because no window has focus there focused application may add window when finishes starting up. i/windowmanager( 725): input event dispatching timed out sending application appwindowtoken reason: waiting because no window has focus there focused application may add window when finishes starting up.
what doing wrong , how can fix it?
why go lengthy process while have easy one. @chen commented above can start mainacitivity
this
new handler().postdelayed(new runnable() { @override public void run() { startactivity(new intent(splashactivity.this, mainactivity.class)); finish(); } }, 3000);
happy_coding... :)
Comments
Post a Comment