Wednesday, July 13, 2011

[android-developers] Prompting a user once

New to Android and playing with GPS settings. I've successfully been
able to get my location and find the nearest locations based on a
personal database. So far I have two activities. Activity 1 is a menu
with an option to go the 2nd activity and in the future more menu
options etc. In my second activity, i call an AlertDialog during
onStart() to prompt the user asking whether he'd like to turn his GPS/
location settings on. if they choose yes, then it calls an intent for
the location source settings. Here's how I do that.

private void openLocationMenu() {
final ComponentName toLaunch = new
ComponentName("com.android.settings","com.android.settings.SecuritySettings");
final Intent gpsIntent = new
Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
gpsIntent.addCategory(Intent.CATEGORY_LAUNCHER);
gpsIntent.setComponent(toLaunch);
gpsIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivityForResult(gpsIntent,0);
}


Now, once I go back to my second activity after choosing their gps
settings, I do not want my AlertDialog to be called again which it
does because it's in the onStart() part of the UI flow.

How do I have the app "remember" that it's already called the
AlertDialog and the user's gone through those location steps already??
obviously onStart() seems like the wrong place to put this method...
can anyone help?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment