Android - How to restart a clean application instance -
i'm using android bluetooth library connect remote desktop. when connection desktop lost, i'd restart fresh instance of application (that highly facilitate handling of connection lost).
i tried code :
intent = getbasecontext().getpackagemanager() .getlaunchintentforpackage( getbasecontext().getpackagename() ); i.addflags(intent.flag_activity_no_history); i.addflags(intent.flag_activity_clear_top); startactivity(i);
but after that, still have trouble reconnecting whereas if manually kill , restart application works fine.
you can restart activity
when detect you've lost , found again connection. can restart activity code:
public void reload() { intent intent = getintent(); overridependingtransition(0, 0); intent.addflags(intent.flag_activity_no_animation); finish(); overridependingtransition(0, 0); startactivity(intent); }
Comments
Post a Comment