android - Stop an intent after a redirection to setting menu -


i'm developing app uses gps location on googlemaps view. check if gps feature activated, , if not redirect user setting menu.

  1. if click on button (by activating or not gps) come app - works fine
  2. if click on home button, , relaunch app, directly redirected gps setting menu => intent still on.
    problem not know when kill intent.

here incriminated part of code:

    button btnlocateme = (button)findviewbyid(rsendlocationinfo.id.locateme);     btnlocateme.setonclicklistener(new onclicklistener() {          public void onclick(view v) {              context context = getapplicationcontext();              objgps = (locationmanager)getsystemservice(context.location_service);               //check gps configuration             if ( !objgps.isproviderenabled( locationmanager.gps_provider ) ) {                    //warn user gps not activated                 toast gpsactivationcheck = toast.maketext(context, "gps deactivated - touch open gps settings.", toast.length_long);                 gpsactivationcheck.show();                  //open gps settings menu on next ontouch event                 //by implementing directly listener method - dirt manner                 mapview.setontouchlistener(new ontouchlistener() {                     public boolean ontouch(view v, motionevent event) {                            //and here problem - how kill process                         startactivityforresult(new intent(android.provider.settings.action_location_source_settings), 0);                            return false;                     }                 });                   }             else {                   //location acquisition.               }   

i tried stopself(), finish(), in onstop(), ondestroy(), onpause()... crashes or not anything... please give me hand ?

ok, have found.
try explain difference in behavior clearly:

  1. old behavior:

    • launch application
    • google maps activity starts
    • user accepts redirection setting menu activate gps
    • setting menu displayed
    • user click on "home" button
    • user relaunch application => setting menu displayed, latest intent in history stack of application.

the code launch intent was:

startactivityforresult(new intent(android.provider.settings.action_location_source_settings), 0); 
  1. new behavior:

    • launch application
    • google maps activity starts
    • user accepts redirection setting menu activate gps
    • setting menu displayed
    • user click on "home" button
    • user relaunch application => google maps displayed, , not setting menu, because have added flag flag_activity_no_history redirection intent.

my code now:

intent intentredirectiongpssettings = new intent(android.provider.settings.action_location_source_settings); intentredirectiongpssettings.addflags(intent.flag_activity_no_history);  startactivityforresult(intentredirectiongpssettings, 0); 

i tried explain well. tag "android:nohistory(true)" in manifest.xml works activities, flag flag_activity_no_history alternative, works intents.

thank help.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -