Java android eclipse, starting activity in thread: application stopped working -
hey doing simple android app , trying start new activity thread this:
public void startui (){ thread t = new thread(){ public void run () { runonuithread(new runnable() { @override public void run() { intent gotomenu = new intent(getapplicationcontext(), mainmenu.class); startactivity(gotomenu); } }); ;} }; t.start; }
but when code comes line
intent gotomenu = new intent(getapplicationcontext(), mainmenu.class);
it crashes , writes: "application stopped working".
if want start activity need use activity
context first parameter. if use application
context mainmenu
activity must have flag_activity_new_task
flag set. cannot start new activity in same task application context.
refer: http://developer.android.com/reference/android/content/intent.html#flag_activity_new_task
as @raghunandan mentioned, if want delay, should use handler
this:
uihandler.postdelayed(new runnable() { @override public void run() { intent gotomenu = new intent(getapplicationcontext(), mainmenu.class); gotomenu.addflags(intent.flag_activity_new_task); startactivity(gotomenu); } }, 500);
Comments
Post a Comment