summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Chung <fchung@google.com>2012-04-17 09:54:27 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-04-17 09:54:27 -0700
commit21f6c5b84a3a79b21156199dff24c8b36c57679e (patch)
tree60d2a8f837877b9ac6f60f8a707a5741e094f8a6
parent3a59d6e26dbec61ede7d6f87d966698e27c91d78 (diff)
parent5a1cf3661c9b47ca682511f248987e680768e530 (diff)
downloadframeworks_base-21f6c5b84a3a79b21156199dff24c8b36c57679e.zip
frameworks_base-21f6c5b84a3a79b21156199dff24c8b36c57679e.tar.gz
frameworks_base-21f6c5b84a3a79b21156199dff24c8b36c57679e.tar.bz2
am 5a1cf366: am fe71253b: am 3d467946: Merge "Updated "Making your App Location Aware" class to include information on location provider enable check." into ics-mr1
* commit '5a1cf3661c9b47ca682511f248987e680768e530': Updated "Making your App Location Aware" class to include information on location provider enable check.
-rw-r--r--docs/html/shareables/training/LocationAware.zipbin36310 -> 261408 bytes
-rw-r--r--docs/html/training/location/locationmanager.jd30
2 files changed, 30 insertions, 0 deletions
diff --git a/docs/html/shareables/training/LocationAware.zip b/docs/html/shareables/training/LocationAware.zip
index 46970cd..8ed97cb 100644
--- a/docs/html/shareables/training/LocationAware.zip
+++ b/docs/html/shareables/training/LocationAware.zip
Binary files differ
diff --git a/docs/html/training/location/locationmanager.jd b/docs/html/training/location/locationmanager.jd
index 5da1205..61abcbd 100644
--- a/docs/html/training/location/locationmanager.jd
+++ b/docs/html/training/location/locationmanager.jd
@@ -18,6 +18,7 @@ next.link=currentlocation.html
<li><a href="locationmanager.html#TaskDeclarePermissions">Declare Proper Permissions in Android Manifest</a></li>
<li><a href="locationmanager.html#TaskGetLocationManagerRef">Get a Reference to LocationManager</a></li>
<li><a href="locationmanager.html#TaskPickLocationProvider">Pick a Location Provider</a></li>
+ <li><a href="locationmanager.html#TaskVerifyProvider">Verify the Location Provider is Enabled</a></li>
</ol>
<h2>You should also read</h2>
@@ -88,3 +89,32 @@ if (providerName != null) {
...
}
</pre>
+
+<h2 id="TaskVerifyProvider">Verify the Location Provider is Enabled</h2>
+
+<p>Some location providers such as the GPS can be disabled in Settings. It is good practice to check whether the desired location provider is currently enabled by calling the {@link android.location.LocationManager#isProviderEnabled(java.lang.String) isProviderEnabled()} method. If the location provider is disabled, you can offer the user an opportunity to enable it in Settings by firing an {@link android.content.Intent} with the {@link android.provider.Settings#ACTION_LOCATION_SOURCE_SETTINGS} action.</p>
+
+<pre>
+&#64;Override
+protected void onStart() {
+ super.onStart();
+
+ // This verification should be done during onStart() because the system calls
+ // this method when the user returns to the activity, which ensures the desired
+ // location provider is enabled each time the activity resumes from the stopped state.
+ LocationManager locationManager =
+ (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+ final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ if (!gpsEnabled) {
+ // Build an alert dialog here that requests that the user enable
+ // the location services, then when the user clicks the "OK" button,
+ // call enableLocationSettings()
+ }
+}
+
+private void enableLocationSettings() {
+ Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ startActivity(settingsIntent);
+}
+</pre>