Doubts about uses feature android.hardware.location.network and android.hardware.location.gps

2

I am somewhat confused with this issue and I would like to see if someone who has it clearer could explain to me well what it is about or answer the following questions.

Does this change apply to applications compiled with api 21+ or does it apply only if your minimum required amount is 21 +?

What happens if the minimum api of my application is 15 and the maximum is 24, should I add that feature?

my application uses GPS and / or Network for the location.

Greetings.

    
asked by Bourne 12.10.2016 в 16:55
source

3 answers

3

Based on your question, I share this information that Google sent on September 20 regarding the use of android.hardware.location.gps (I translate the original email):

  

From: Google Play Date: 2016-09-20   1:38 PM GMT-05: 00 Subject: Google Play change to Android   ACCESS_FINE_LOCATION permissions

     

Action required: If your application requires GPS hardware to operate   properly, you need explicitly to add    "android.hardware.location.gps" uses-feature to your file    Manifest.xml .

     

In the future, these applications will be available to install on   devices that do not have GPS hardware. In most cases   this will not be a problem since Wi-Fi and ID based on   location provides a high fidelity that is sufficient for the   Typical operation of these applications.

     

However, none of the applications that require GPS hardware,   such as GPS navigators, they must explicitly add the    "android.hardware.location.gps" uses-feature to your file    Manifest.xml .

     

If your application requires GPS to work properly and you do not include android.hardware.location.gps in the declaration of your manifest.xml , your users may experience a poor experience in the application.

Based on the information, you get that if you have defined a targetSdkVersion in your Manifest.xml or build.gradle (remember that build.gradle overwrite the properties) defined as 21 or greater:

 android:targetSdkVersion=21

to use:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

but has not specified:

<uses-feature
    android:name="android.hardware.location.gps"
    android:required="false" />

This type of applications can be installed on devices that do not have GPS. that is, specifying that the gps hardware may not be required in the Manifest.xml , will not be necessary in the future, this will help to avoid filtering certain devices in the playstore for your application, which do not have this hardware , but if your application really uses it, you need to declare it in the manifest.xml so that it works properly.

About the use of android.hardware.location.network and android.hardware.location.gps .

If your application has a targetSdkVersion defined as 21 or later:

android:targetSdkVersion=21

You must declare that your application uses android.hardware.location.network or android.hardware.location.gps .

This is if you are using any of the providers NETWORK_PROVIDER ( android.hardware.location.network ) or GPS_PROVIDER ( android.hardware.location.gps )

example:

<manifest ... >
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    ...
    <!-- Se necesita si tu aplicación tiene target 5.0 (API 21) o posterior. -->
    <uses-feature android:name="android.hardware.location.network" />
    <uses-feature android:name="android.hardware.location.gps" />
    ...
</manifest>
    
answered by 13.10.2016 / 21:17
source
1

minSdkAndroid

is the minimum version of Android that your application supports, specified using the API Levels. For your application to work on as many devices as possible, you should set this value to the minimum version that allows you to implement the main features of your application. If there is some functionality that can only be implemented in new versions of Android and is not a critical functionality, you can enable it only if you are running a version that supports it (as explained in Supporting different versions of the platform). For this example, leave this option at its default value.

targetSdkAndroid

is the most modern version of Android with which you have tested your application (again using the API Level). When a new version of Android comes out, you should check that your application is still working in the new version and update this value to match the latest API level to take advantage of the new features of the platform.

It is possible that some libraries, classes, widgets, functions and android methods are not compatible between versions. for example, HTTP calls were included until version 4.1 of Android.

    
answered by 12.10.2016 в 18:46
1

The change only affects the applications that run in Android 5.0 API 21 or higher , and what it means is that if you use (and this is the case) the definitions ACCESS_COARSE_LOCATION and / o ACCESS_FINE_LOCATION you must explicitly declare the android.hardware.location.network and / or android.hardware.location.gps methods. In previous APIs , if you used those statements it was implicit that you used those methods, that is, it was not necessary to declare them.

    
answered by 13.10.2016 в 01:05