le chiffre
le chiffre

Reputation: 321

onDestroy() gets called when calling startActivityForResult()

I have a problem returning from the GPS Settings. I want to check if GPS is enabled, but for some reasons not only onStop() gets called from the calling Activity, but also onDestroy and when I return from the Settings I arrive at the Main Screen as the Activity has been destroyed. I don't know what triggers this behavior as in another App the same Code works and returns. Its a simple call :

    case(GPS_SWITCHER):{
          Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
         //intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
         startActivityForResult(intent,REQUEST_CODE);
    }

I tried working with the flags for the Intent but that did not solve it. I also tried calling the Intent from a PreferenceActivity, but already this call kills the Main app :-) Any ideas ?

Thank you !

Upvotes: 3

Views: 1694

Answers (2)

Guillaume
Guillaume

Reputation: 22822

You forgot break; in your case statement. That means the code immediately below is executed too.

Upvotes: 1

Shailendra Singh Rajawat
Shailendra Singh Rajawat

Reputation: 8242

check if you write noHisory="true" in activity tag of Manifest file and remove it . also check for other inappropriate parameter .

Upvotes: 5

Related Questions