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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -