diff --git a/docs/html/guide/topics/location/strategies.jd b/docs/html/guide/topics/location/strategies.jd index 2dfed2ce6e8e4..eb436d0138a46 100755 --- a/docs/html/guide/topics/location/strategies.jd +++ b/docs/html/guide/topics/location/strategies.jd @@ -133,36 +133,66 @@ notifications and the third is the minimum change in distance between notificati both to zero requests location notifications as frequently as possible. The last parameter is your {@link android.location.LocationListener}, which receives callbacks for location updates.
-To request location updates from the GPS provider,
-substitute GPS_PROVIDER for NETWORK_PROVIDER. You can also request
-location updates from both the GPS and the Network Location Provider by calling {@link
-android.location.LocationManager#requestLocationUpdates requestLocationUpdates()} twice—once
-for NETWORK_PROVIDER and once for GPS_PROVIDER.
To request location updates from the GPS provider, use {@link +android.location.LocationManager#GPS_PROVIDER} instead of {@link +android.location.LocationManager#NETWORK_PROVIDER}. You can also request +location updates from both the GPS and the Network Location Provider by calling +{@link android.location.LocationManager#requestLocationUpdates +requestLocationUpdates()} twice—once for {@link +android.location.LocationManager#NETWORK_PROVIDER} and once for {@link +android.location.LocationManager#GPS_PROVIDER}.
In order to receive location updates from NETWORK_PROVIDER or
-GPS_PROVIDER, you must request user permission by declaring either the {@code
-ACCESS_COARSE_LOCATION} or {@code ACCESS_FINE_LOCATION} permission, respectively, in your Android
-manifest file. For example:
+ In order to receive location updates from {@link + android.location.LocationManager#NETWORK_PROVIDER} or {@link + android.location.LocationManager#GPS_PROVIDER}, you must request the user's + permission by declaring either the {@code ACCESS_COARSE_LOCATION} or {@code + ACCESS_FINE_LOCATION} permission, respectively, in your Android manifest file. + Without these permissions, your application will fail at runtime when + requesting location updates. +
++ If you are using both {@link + android.location.LocationManager#NETWORK_PROVIDER} and {@link + android.location.LocationManager#GPS_PROVIDER}, then you need to request only + the {@code ACCESS_FINE_LOCATION} permission, because it includes permission + for both providers. (Permission for {@code ACCESS_COARSE_LOCATION} includes + permission only for {@link + android.location.LocationManager#NETWORK_PROVIDER}.) +
+ +
+ Note: If your app targets Android 5.0 (API level 21) or
+ higher, you must also declare that your app uses the
+ android.hardware.location.network or
+ android.hardware.location.gps hardware feature in the manifest
+ file, depending on whether your app receives location updates from {@link
+ android.location.LocationManager#NETWORK_PROVIDER} or from {@link
+ android.location.LocationManager#GPS_PROVIDER}. If your app receives location
+ information from both of these providers, you need to declare that the app
+ uses both android.hardware.location.network and
+ android.hardware.location.gps.
+
+ The following code sample demonstrates how to declare the permission and + hardware feature in the manifest file of an app that reads data from the + device's GPS: +
<manifest ... >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
...
+ <!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
+ <uses-feature android:name="android.hardware.location.gps" />
+ ...
</manifest>
-Without these permissions, your application will fail at runtime when requesting -location updates.
- -Note: If you are using both NETWORK_PROVIDER and
-GPS_PROVIDER, then you need to request only the {@code ACCESS_FINE_LOCATION}
-permission, because it includes permission for both providers. (Permission for {@code
-ACCESS_COARSE_LOCATION} includes permission only for NETWORK_PROVIDER.)
Location-based applications are now commonplace, but due to the less than optimal @@ -404,9 +434,10 @@ don't have a device, you can still test your location-based features by mocking the Android emulator. There are three different ways to send your application mock location data: using Android Studio, DDMS, or the "geo" command in the emulator console.
-Note: Providing mock location data is injected as GPS location
-data, so you must request location updates from GPS_PROVIDER in order for mock location
-data to work.
Note: Providing mock location data is injected +as GPS location data, so you must request location updates from {@link +android.location.LocationManager#GPS_PROVIDER} in order for mock location data +to work.
<uses-feature android:name="android.hardware.camera" android:required="false" />+
+ Note: If your app targets Android 5.0 (API level 21) or
+ higher and uses the ACCESS_COARSE_LOCATION or
+ ACCESS_FINE_LOCATION permission in order to receive location
+ updates from the network or a GPS, respectively, you must also explicitly
+ declare that your app uses the android.hardware.location.network
+ or android.hardware.location.gps hardware feature, respectively.
+
Table 2. Device permissions that imply device hardware use.
@@ -1717,14 +1726,29 @@ densities: '160'ACCESS_COARSE_LOCATIONandroid.hardware.location.network and
-android.hardware.location
+ android.hardware.location
+
+ android.hardware.location.network (Target API level 20 or
+ lower only.)
+
ACCESS_FINE_LOCATIONandroid.hardware.location.gps and
-android.hardware.location
+ android.hardware.location
+
+ android.hardware.location.gps (Target API level 20 or lower
+ only.)
+
Location Permission - If your application tags images + with GPS location information, you must request the "fine location" + permission. Note that, if your app targets Android 5.0 (API level 21) or + higher, you also need to declare that your app uses the device's GPS:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> +... +<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. --> +<uses-feature android:name="android.hardware.location.gps" />
For more information about getting user location, see Location Strategies.
diff --git a/docs/html/training/tv/start/hardware.jd b/docs/html/training/tv/start/hardware.jd index 97cf7ff6626d0..063987159b797 100644 --- a/docs/html/training/tv/start/hardware.jd +++ b/docs/html/training/tv/start/hardware.jd @@ -227,13 +227,19 @@ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION){@code android.hardware.location}
+{@code android.hardware.location.network} (Target API level 20 or lower + only.)
+{@code android.hardware.location}
+{@code android.hardware.location.gps} (Target API level 20 or lower + only.)
+
+ Note: If your app targets Android 5.0 (API level 21) or
+ higher and uses the ACCESS_COARSE_LOCATION or
+ ACCESS_FINE_LOCATION permission, users can still install your
+ app on a TV device, even if the TV device doesn't have a network card or a GPS
+ receiver.
+