Sorry, that questions sound stupid but drives me crazy.
I'm about implementing an app very similar to the Bluetooth App described in Developer Android.
I don't get required permissions, though.
Yes, I ask for permission twice
a) in my manifest
b) and I check before using BT with
ActivityCompat.requestPermissions(..)
In logcat, see belove, I learn that my app doesn't get Bluetooth permission.
It isn't the first time I write a BT app. LAst time it was fine. But was a while ago.
My mobile (Nexus 5) told me something about Development Mode Active and apps would be routed to Developer Manager to be started as instant app.
I also learned that Bluetooth access is not granted to instant apps at all.
(I understand that.).
Could that be the problem? Does Android Studio produce different apps now. Does it interact in a different manager with the test hardware?
If so, how do I pursuade Android Studio to not produce an instant app?
Thank you so much in advance.
my manifest code
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Log output:
android.permission.BLUETOOTH: denied
and some lines earlier
I/ActivityManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.packageinstaller cmp=com.google.android.instantapps.supervisor/.permissions.GrantPermissionsTrampoline (has extras)} from uid 10029 on display 0
W/Isotope: UID: [10029] PID: [14812] GrantPermissionsTrampoline : Permission not allowed: android.permission.BLUETOOTH
Sorry for bothering you... It was so easy. I have just deactivated that instant apps dev manager on my Android phone.
Voila, my app is an app again and no instant app. It gets all
permissions it need. Anything is fine.
I'm sorry again.
Related
I'm developing an app that uses Nearby Connections API with basic P2P strategy. Suddenly, weirdly enough I'm not able to advertise and discover devices on my Pixel 3a with newest Android 12 and Play Services. OnFailureListeners throw these exceptions:
for discovering: 8037: unknown status code: 8037
for advertising: 8038: unknown status code: 8038
Indeed they cannot be found in docs and source code.
I also checked Google's "Rock Papers Scissors" official sample and it throws the same error codes.
Of course I reinstalled the app and restarted & updated my phone. EDIT: I also did the factory reset and it didn't help. But after I downgraded to latest Android 11 using Android Flash Tool, it started working again. Moreover, everything still works fine on Android 11, 10 and 9 using different phones.
Any ideas what causes this issue? It just worked fine for last two weeks and stopped working today. I believe it needs some deep investigation in source code (Xlythe if I may ask for your help, that would be really great).
After a while I finally managed to find a solution. It looks like Nearby Connections (all Nearbys?) have a critical bug on Android 12 that happens non-deterministically (API can work fine for few weeks then suddenly will throw these errors for another few weeks).
This bug is related to Android 12's feature change related to Bluetooth. Quoting:
Android 12 introduces the BLUETOOTH_SCAN, BLUETOOTH_ADVERTISE, and BLUETOOTH_CONNECT permissions. These permissions make it easier for apps that target Android 12 to interact with Bluetooth devices, especially for apps that don't require access to device location.
In other words, some Bluetooth permissions are now legacy and there are some new permissions that are mandatory to make the API work. And you need to handle both scenarios in your code (before and after Android 12).
So here's a quick "mapper" from error codes to Manifest's permissions:
Error code 8037 while discovering - you haven't granted permission
for BLUETOOTH_SCAN
Error code 8038 while advertising - you haven't granted permission for BLUETOOTH_ADVERTISE
Error code 8039 (that's a new one as well) while onEndpointFound - you haven't granted permission for BLUETOOTH_CONNECT
More information how to implement new permissions properly can be found in documentation.
And I'm still waiting for Google to fix it in next Nearby API update as this is a little bit of workaround. Adding proper error messages to codes might be a little work to do but I would also revise if other permissions are still required after Android 12's update.
My App has a background service which keeps running as foreground service. This service controls the device WiFi/Bluetooth programmatically on certain conditions. Everything works fine BUT on few devices (specifically the devices with custom ROMs) this is failing with the permission error. For example on OppoF9, I am getting below messages in the logcat:
D OppoPermissionInterceptPolicy: not foreground app, reject it! <My App Package>
W ServiceManager: Permission failure: android.permission.CHANGE_WIFI_STATE from uid=10424 pid=8894
E CheckPermission: Permission Denial: can't change wifi state pid=8894, uid=10424
I am not sure weather this issue is related with "adding the app under white listed categories" in few devices(again for devices with custom ROMs).
So,
Is this device specific issue (Which I predict as "YES")?
Is there any possible solution (Programatically possible solution OR manual settings before trying my service on these phone)?
Any suggestions how to fix it? TIA.
I'm a newbie with android development. So far I have developed an application which uses SMSManager.
I'm testing my application on an active device when it reaches smsManager.sendTextMessage it throws exception of android.premission.SEND_SMS.
I know that I have to get device permission.
My Question is:
Can I send SMS while uploading application right from IDE, or have to install .apk manually?
You must add the following permissions in your Manifest file:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
If you install the application via debugging/IDE/ADB it will automatically get the permissions you require in your manifest.
So: Yes! When run on the device through the debugger, the application will be able to send test messages.
Bonus information: If you do "stuff" that the application doesn't have the proper permissions for, the debugger will give you exceptions and hints to what is wrong.
I have a (FOSS) app out there which can, among other features, enable and disable Wifi.
AndroidManifest.xml contains android.permission.CHANGE_WIFI_STATE, unit tests on the emulator pass and the feature works on a real device, a HTC Desire running 2.2.2.
The SDK versions are android:minSdkVersion="7" and android:targetSdkVersion="10", so I can't say about newer releases of Android.
I have received one single crash report:
java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider
uri content://settings/secure from pid=6191,
uid=10114 requires android.permission.WRITE_SETTINGS
Is android.permission.WRITE_SETTINGS possibly required on recent versions of Android? The reference says the permission exists since API 1, so I'd be surprised why it wasn't on older releases.
The user message is weird, it just says "lies", so I am unsure if I should just follow this report and add android.permission.WRITE_SETTINGS.
Any thoughts?
Cheers,
Torsten
That's weird, cause I needed to check exactly the same issue, so i just wrote a few lines of code doing exactly just that : enable/disable wifi and bluetooth.
My conclusion: you dont need the WRITE_SETTINGS permission to toggle the wifi, nor the bluetooth for that matter.
wifi = access_wifi_state + change_wifi_state
BT = bluetooth + bluetooth_admin
(with 4.2.2)
Check whether you were trying something else too, which may trigger the exception ?
In my application descriptor file there is this line:
<!--Removing the permission android.permission.INTERNET will have the side effect
of preventing you from debugging your application on your device-->
<uses-permission android:name="android.permission.INTERNET"/>
Does this mean I won't be able to debug my application with Flash Builder or does it mean that if my app crashes as a user is running it I won't get error reports in Google App developer center?
Nope and No! This is just a permission it wouldn't affect any of the above. It just allows your application to connect to Internet.
But maybe your application needs Internet just to work properly.
ANR and Crash reporting is integrated into OS, and handled via Play Store services. It has nothing to do with your App's permissions.