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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -