Can I get access to NFC without manifest permission in android? - android

I need to create app with optional NFC functionality.
Can I get access to NFC without manifest permission (Android)? Or should I create two apps: an NFC version and one without it.

Updated as per finding of thorbear
The uses-feature element so that your application shows up in Google Play only for devices that have NFC hardware:
<uses-feature android:name="android.hardware.nfc" android:required="true" />
If your application uses NFC functionality, but that functionality is not crucial to your application, you can omit the uses-feature element and check for NFC avalailbility at runtime by checking to see if getDefaultAdapter() is null.
This is not possible without adding permission into manifest. And you
do not required to create two apps for such case.
Read Requesting NFC Access in the Android Manifest for more details
But yes you have a way to say "My application uses NFC feature but optional".
For this you need to add <uses-feature android:name="android.hardware.nfc" android:required="false" /> into manifest. So Google play can make your application available for all devices which have NFC or not have.
Note : If you do not add this <uses-feature .../> tag into manifest with android:required="false", Google Play will treat your application as "this application is only for devices which having NFC". And a device which does not have NFC feature, can not download your application from Google Play.
Here is manifest example
<manifest ...>
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<uses-permission android:name="android.permission.NFC" />
</manifest>
Read more about <uses-feature>

You can't get access to NFC without adding the following permission to your manifest.
<uses-permission android:name="android.permission.NFC" />

Related

Android application visibility on tablet in play store

I use the following permission in my application
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
and i made a sample application which is not visible in play store for tablet devices.
So my question is, for which permission google is not showing the app for tab devices?
i know some tablet devices dont have sim, so sms permission could be it, but tab which has sim in it, also cant see the app in play store.
Aside from minSdkVersion that may affect visibility, your Manifest may lack support-screens tag:
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true"/>
#Shofiqul Alam
If you add any permission in manifest file then forces that only those devices can use this application which have these abilities.
In your case you have added permissions for receiving and sending SMS and for Fine Location
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
So if the device have not the ability to provide FINE LOCATION then it can't visible on play store. So be sure the device must fulfill the requirement for location(Is device has GPS feature).
If this feature is not compulsory in your app then add the Line of code in your manifest
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
It will not not force the devices to have GPS ability.
Also you may follow the link below:
GPS Manifest: GPS in App is optional, want to make it available to GPS less devices too
As far as I know, permissions do not affect the app's visibility in the Play Store. The <uses-feature> tag will limit visibility (depending if it is required or not).
Also for your app to be visible for tables you must upload some 7" and 10" screenshots.
One last thing, android checks the xml layouts for a tablet-specific file, it had happened to me once that I used the same layout file for both phones and tablets (I did some custom drawing) but I was getting a warning in the play store.

My App is not compatible on WiFi only devices

I developed an android app which shows the caller's Telecom Location on Incoming Call.
I uploaded it on Google Play, but this app does not appear on WiFi only devices, it says your device is not compatible .
My Manifest permission details are below.
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
I doubt about following permissions
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Which particular permissions are creating problem?
What is the solution.
Thanks
The google play store filters applications based on the permissions they require and the features available in the android device. So, your app will not show up in WiFi only devices because the app requires the CALL_PHONE permisssion and the MODIFY_STATE_PERMISSION.
The MODIFY_PHONE_STATE permission does not allow you to place calls but it implies that telephony is a requirement.
Source : https://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions
Hence, you should use the <uses-feature> element instead of the above mentioned permissions.
From Docs : You can disable filtering based on the implied feature by explicitly declaring the implied feature, in a element, with an android:required="false" attribute.
In your case :
<uses-feature android:name="android.hardware.telephony" android:required="false" />
But then you also need to ensure that you do not use any of the telephony related features before actually checking if it's available of not.
In the android app, for SDK >=5 , you should use :
PackageManager pm = this.getPackageManager();
boolean hasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
You are correct to suspect the following...
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Certain permissions "imply" the necessity for certain hardware to exist. In other words, permissions relating to the phone require the device to have phone capabilities (obviously).
You can get around this by using the <uses-feature> element in the AndroidManifest.xml. This allows you to specify if the 'feature' is required or not.
Take a look at the documentation for <uses-feature-element>
In particular the Permissions that Imply Feature Requirements section which explains the requirements related to the <uses-permission> elements.
EDIT: One more thing - if a feature CAN be used but it's not REQUIRED, it is up to you to check for its availability in your code before attempting to use it otherwise you'll get unpredictable results or possible exceptions / crashes.

<uses feature> tan in android

<uses-permission android:name="android.permission.PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
I have basically declares this in the manifest. I want to know what exactly uses feature does.
From my understanding, if i declared permission access_coarse_location and all that, this means my app uses feature android.hardware.location ..and for that automatically thats set for true.
By specifying that feature to false, am telling android store..that a user can download this app even if he doesn't have location hardware..because this thing is handled inside code?
Is my understanding right? Because i find it funny there is feature android.hardware.wifi ..
what phone, mobile device doesn't have a wifi?
yup your understanding is correct.
From https://developer.android.com/guide/topics/manifest/uses-feature-element:
Google Play uses the elements declared in your app
manifest to filter your app from devices that do not meet it's
hardware and software feature requirements. By specifying the features
that your application requires, you enable Google Play to present your
application only to users whose devices meet the application's feature
requirements, rather than presenting it to all users
I want to know what exactly uses feature does
Quoting the documentation:
The purpose of a declaration is to inform any external entity of the set of hardware and software features on which your application depends. The element offers a required attribute that lets you specify whether your application requires and cannot function without the declared feature, or whether it prefers to have the feature but can function without it. Because feature support can vary across Android devices, the element serves an important role in letting an application describe the device-variable features that it uses.
Here, "external entity" usually means an app distribution channel, like the Play Store.
Is my understanding right?
Yes. One role of <uses-feature> is to indicate that some feature is not required, where a permission would imply that it is required.
Because i find it funny there is feature android.hardware.wifi .. what phone, mobile device doesn't have a wifi?
There is no requirement that Android devices support WiFi. For example, Android is used in vehicles, from cars to the Boeing 787 Dreamliner, and those environments may not offer WiFi.
You are correct in your understanding. The uses tag is mainly for filtering on the play store. Which means that users who may have a device that doesn't support a required feature that your app depends on, will not see your app in the listings.
As an aside. There are plenty of Android devices which don't feature a wireless chipset. I've been working with Android based Barcode scanners that don't have Wifi, nor GPS services. It's always best to handle things in code, depending on what the device is capable of.
Hope this helps.

How to allow download on an Android device without BT if BT is in manifest

I have an app the optionally requires BT - so I put
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
in the manifest.
The problem is that this filters out all Android devices which do not have BT.
But I need to make it optional! So they should be still compatible so that users can install the app from GooglePLay - I will just deactivate the BT option in the app in that case.
Is that possible?
Add this to your AndroidManifest.xml:
<uses-feature android:name="android.hardware.bluetooth"
android:required="false"/>
This is what the docs say about Play Store filtering through use of permissions:
In some cases, the permissions that you request through can affect how your application is filtered by Google Play.
If you request a hardware-related permission — CAMERA, for example — Google Play assumes that your application requires the underlying hardware feature and filters the application from devices that do not offer it.
To control filtering, always explicitly declare hardware features in elements, rather than relying on Google Play to "discover" the requirements in elements. Then, if you want to disable filtering for a particular feature, you can add a android:required="false" attribute to the declaration.

Android market filtering issue

I have created an app that check if WIFI/GPS is enabled in a mobile phone along with some other data..
If WIFI is enabled then will do some action else it will skip that portion.. So this basically means that Availability of WIFI/GPS is not a requisite for my app..
But after uploading my app in the android market, it shows..
This apk requests 4 features that will be used for Android Market filtering
android.hardware.wifi
android.hardware.location
android.hardware.location.gps
android.hardware.touchscreen
All these 4 is not a requisite for my app.. then why its showing that my app will be filtered based on these..
Also if i set the tag to false in my android manifest will my app be visible to all the phones especially those without touchscreen,wifi,gps and all???
<uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
Will my app be visible to all phones irrespective of any filtering if i set the tag to false ???
You want to set android:required to false. What that tag means (when you set the attribute to false) is that your app could use that feature, but doesn't require that the phone have it to run - which is what you want, it sounds like.
In my opinion, that's not a bad thing. If somebody wants an app that uses GPS, they won't filter against it.
If your app secretly uses GPS to track them, then they'll know their "Game" uses GPS so it works for them, and you'll get a bad review.

Categories

Resources