My app uses Bluetooth LE but it's not required, I've added:
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
Into the manifest but I'm still seeing it listed as a feature when uploading the apk to play store.
Eligibility of devices has plummeted since adding this permission and not sure if this is a bug in the android framework or I'm missing something.
Looks like you are doing it correctly by declaring it in your manifest
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
then using a block like this when you need to use the capability.
// Use this check to determine whether BLE is supported on the device. Then
// you can selectively disable BLE-related features.
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) {
Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
finish();
}
Seems like it's treating it like you put in true. Do you have any other manifests declared that are maybe being merged together and fouling the result manifest?
Turns out my issue was with the Estimote SDK, I found this line in the document:
Android Estimote SDK requires certain permissions in order to function
properly. Luckily, there’s no extra steps you need to take here. The
permissions are defined in the SDK’s manifest file and are
automatically merged into your app’s AndroidManifest.xml, so you don’t
need to declare them by hand.
So I decided to upgrade the library to the latest version and now my app doesn't require the Bluetooth LE feature.
Related
I am trying to create a new release of my Codename One app for Android. When I upload the APK to the Google Play Console, I get an error that my APK uses android.permission.READ_PHONE_STATE and that I do need a privacy policy to be able to use that permission.
In the Codename One blog I read:
android.permission.READ_PHONE_STATE - is triggered by com.codename1.ads package, com.codename1.components.Ads, com.codename1.components.ShareButton, com.codename1.media, com.codename1.push, Display.getUdid() & Display.getMsisdn(). This permission is required for media in order to suspend audio playback when you get a phone call.
But my app does not use ads, does not use sharing, does not use media, does not use push and does not use UDID nor MSISDN. Hence, I have no clue why I would need this permission (which indeed is present in the generated APK).
How can I prevent this permission being added to the APK (or how can I detect why this permission is added).
#
#Sat Sep 28 17:12:49 BST 2019
codename1.vendor=Frans van Gool
codename1.displayName=S\u00F3 Verbos
codename1.icon=/C\:/EclipseData/JustVerbs/GaloDeBarcelos.png
codename1.arg.java.version=8
codename1.languageLevel=5
codename1.secondaryTitle=S\u00F3 Verbos
codename1.version=1.20
codename1.mainName=Main
codename1.ios.certificatePassword=
codename1.arg.ios.newStorageLocation=true
codename1.rim.signtoolDb=
libVersion=212
codename1.ios.certificate=
codename1.android.keystorePassword=**************
codename1.j2me.nativeTheme=nativej2me.res
codename1.rim.signtoolCsk=
codename1.android.keystore=/C\:/eclipseData/JustVerbs/keychain.ks
codename1.android.keystoreAlias=justverbs
codename1.rim.certificatePassword=
codename1.ios.provision=
codename1.packageName=nl.griffelservices.justverbs
Apparently this works (this text has always been here - not sure why it was hidden)
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />
see:
https://facebook.github.io/react-native/docs/removing-default-permissions
(apparently this link no longer works)
I have implemented it but have not tried it (many moons later - I have tried it and it does work). I did not know one could remove permissions in the manifest - first of all I never expected they would get added!
We reviewed your request and found that your app, does not qualify for use of the requested permissions for the following reasons:
The declared feature {Default SMS} is allowed; however we determined it to be unnecessary for the core functionality of your app.
Default SMS [READ_SMS, SEND_SMS, WRITE_SMS, RECEIVE_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS]
I use the <uses-permission android:name="android.permission.SEND_SMS" />
to share the app via SMS (send a text and a link to the website ), whats the work arround?
Thanks
If I understand correctly you want SMS as a feature but not a requirement.
I think what you wanted to do is add uses-feature declarations with android:required="false".
From android docs
When you declare android:required="false" for a feature, it means that the application prefers to use the feature if present on the device, but that it is designed to function without the specified feature, if necessary.
Solved by removing <uses-permission android:name="android.permission.SEND_SMS" />
and calling a intent to open the Native Device Sms App
I am trying to show a live preview of the rear facing camera in Codename One. I use for that the native interface (I am targetting Android first).
To allow my app to use the camera without messing up with build hints, I added these lines in my Main Form :
if (Capture.hasCamera()){
Dialog.show("Appareil photo détecté", "Votre matériel est bien équipé d'un appareil photo!", "OK", null);
}
I did that because Codename One blog stated
android.hardware.camera & android.permission.RECORD_AUDIO - are triggered by com.codename1.Capture
However while debugging the app with the sources I got from CN1 under Android Studio on a real device (API LEVEL 19 aka Kit Kat) I always got a java.lang.RuntimeException: Fail to connect to camera service.
After a while I realized that the exception was due to the lack of the following permission in manifest.xml :
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
Please note that as stated in CN1 blog the line <uses-feature android:name="android.hardware.camera" android:required="false" /> was already added by CN1.
Now that I've added this line the live preview is well shown.
Why is this permission not automatically added in the manifest, should I really add it to the build hint ?
Moreover I have another project that uses the Camera to take photo and save them on the phone and the Camera permission is neither shown (in Android Application Info) nor requested during app installation whereas it works perfectly well. Please note that e.g. Twitter App shows "Take photos and record videos" in the app permissions so it does not seem to be a problem with my phone hiding camera permission.
EDIT November 20th 2016 :
Indeed Android Developer's guide states that
Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission.
That's why CN1 does not require this permission!
Thanks for helping me getting the permission management with CN1 right.
You need to add the following build hint:
android.xpermissions=<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
You can also add this to the cn1lib so it is injected automatically.
In the past, you add the permission you want to your manifest and then it is requested when your user attempts to install your app. As of Android 6.0+, this has changed. Now you can just request a permission when your app needs it for the first time. After the user grants you permission, you don't need to ask again next time. Some benefits of this include keeping your user aware of why you need specific permissions and not requesting permissions that you don't actually need.
You can read more about how to implement it here: https://developer.android.com/training/permissions/requesting.html
There is no way to use a phones camera without asking for permission at some point.
I have the following permission in my manifest:
<uses-permission android:name="android.permission.CAMERA" />
Is this the reason users without cameras on their devices can't download my apps from Google Play?
Is there a way to make this permission OPTIONAL? Meaning... I need to use your camera, but if you don't have one, you can still use my app anyway.
Per the Permissions that Imply Feature Requirements page CAMERA implies android.hardware.camera. You can make it optional by including
<uses-feature android:name="android.hardware.camera" android:required="false" />
I have found a good article which says what is in accepted answer but also adds information how to handle situation when user trys to open camera-related-feature but there is no camera.
Simple code from the article:
// Check that the device will let you use the camera
PackageManager pm = getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// Do camera stuff...
}
permissions don't seem to make any difference...
In the manifest, I have only one <uses-permission> (permission.INTERNET), and I have two <permission> elements:
<permission android:name="myapp.permission.READ"
android:permissionGroup="myapp.permission-group.MYAPP_DATA"
android:label="#string/perm_read"
android:description="#string/perm_read_summary"
android:protectionLevel="signature" />
<permission android:name="myapp.permission.WRITE"
android:permissionGroup="myapp.permission-group.MYAPP_DATA"
android:label="#string/perm_write"
android:description="#string/perm_write_summary"
android:protectionLevel="signature" />
And then there is the provider:
<provider
android:name=".data.DataProvider"
android:multiprocess="true"
android:authorities="myapp.data.DataProvider"
android:readPermission="myapp.permission.READ"
android:writePermission="myapp.permission.WRITE" />
Right now, I have normal access to the ContentProvider, and it works just fine.
Why does it work if I didn't enforce with <uses-permission>?
Shouldn't it be needed also in the app where the provider is
declared?
Adding <uses-permission> with my own permissions make no difference. The permissions are not even listed in the app info. Why?
ps.: yes, I've read questions here on SO and on Google Groups (ones with Hackborn answering, too). I've followed (as you can see) what is described everywhere, but still... You could say that it's working, but the point is exactly that I want to see when it doesn't.
Shouldn't it be needed also in the app where the provider is declared?
AFAIK, your own app holds all your own permissions that you declare. Third parties would need <uses-permission>.
The permissions are not even listed in the app info. Why?
See above.
You could say that it's working, but the point is exactly that I want to see when it doesn't.
Write another app, in its own package, to test your permissions.