You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
am 3d46794: Merge "Updated "Making your App Location Aware" class to include information on location provider enable check." into ics-mr1
* commit '3d467946b2950c6a5e4946c49a33cf4c8d68df20':
Updated "Making your App Location Aware" class to include information on location provider enable check.
Copy file name to clipboardExpand all lines: docs/html/training/location/locationmanager.jd
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ next.link=currentlocation.html
18
18
<li><a href="locationmanager.html#TaskDeclarePermissions">Declare Proper Permissions in Android Manifest</a></li>
19
19
<li><a href="locationmanager.html#TaskGetLocationManagerRef">Get a Reference to LocationManager</a></li>
20
20
<li><a href="locationmanager.html#TaskPickLocationProvider">Pick a Location Provider</a></li>
21
+
<li><a href="locationmanager.html#TaskVerifyProvider">Verify the Location Provider is Enabled</a></li>
21
22
</ol>
22
23
23
24
<h2>You should also read</h2>
@@ -88,3 +89,32 @@ if (providerName != null) {
88
89
...
89
90
}
90
91
</pre>
92
+
93
+
<h2 id="TaskVerifyProvider">Verify the Location Provider is Enabled</h2>
94
+
95
+
<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>
96
+
97
+
<pre>
98
+
@Override
99
+
protected void onStart() {
100
+
super.onStart();
101
+
102
+
// This verification should be done during onStart() because the system calls
103
+
// this method when the user returns to the activity, which ensures the desired
104
+
// location provider is enabled each time the activity resumes from the stopped state.
0 commit comments