Bluetooth BLE readCharacteristic has some error - android

When I use BLE to read the characteristics of the time there are some errors,
Error as follows:
java.lang.SecurityException: Need BLUETOOTH_PRIVILEGED permission: Neither user 10168 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
But I've alredy added appropriate permissions:
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />

You have android.permission.BLUETOOTH_PRIVILEGED in your manifest, but are you sure it was granted? According to https://developer.android.com/reference/android/Manifest.permission.html#BLUETOOTH_PRIVILEGED "This is not available to third party applications"

Related

use bluetooth catch Need BLUETOOTH permission exception on Android12

On Android12 devices, when using the bluetooth features, I get the flowing exception:
java.lang.SecurityException: Need BLUETOOTH permission
android.bluetooth.BluetoothHeadset.<init>(BluetoothHeadset.java:379)
android.bluetooth.BluetoothAdapter.getProfileProxy(BluetoothAdapter.java:3017)
My app's targetVersion is 29, and the related permissions have already declared in manifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
This problem will not happen when the app first loading, but happened after turn on/off the Nearby Devices ipermission. It seem that it will clear the BLUETOOTH permission?

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.

How to access the phone's screen like "Chromecast APP"?(Mirroring)

I want make mirroring without WiFi-direct.
like chromecast mirroring function.
Chromecast application can access screen without
rooting&wifi-direct.
I found "capture_video_output" permission at API 19, but I can`t found any API.
So, I decompiled chromecast, but it hasn't "capture_video_output" permission.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
Is it right way for mirroring?(wifi-display)
How can I make mirroring application?
Or where can I get this info?
You can use Presentation APIs to mirror a view within your app (can be a virtual view) to a chromecast device if mirroring is happening. Otherwise, there is no API for you to mirror phone's screen to a chromecast device.

Android uses-feature in tablet

I have android app with next permissions
<!-- Permissions -->
<uses-permission android:name="android.permission.ACCESS_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.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
But in my samsung tablet i've got This app is not comptable with your tablet. Android 4.2.2
What "uses-feature" I should set as
android:required="false" ?
I'm not sure if the Samsung tablets can vibrate or not, but if they can't, you will need to switch
<uses-permission
to
<uses-feature
And use the required flag. If it is not required, it won't be necessary and will not be filtered because of it. You will have to handle this for tablets that can't vibrate in code if part of your app handles vibrate. If it is not vibrate, then another one of these will be causing the issue and will need to change to uses-feature.
See Uses-Feature
On a secondary note, you should also check you're supporting the larger screen sizes with and not accidentally omitting xlargescreens from the manifest.

Application is not working with wifi on android device

I am making an application in android which integrates twitter and facebook logins and save the logged user info. It is working fine in device with GPRS. But when I am trying to run the application with wifi it gives exception as below.
For Twitter: "Server error"
For Facebook: "DialogError"
please give me some hint to solve this problem.
use permission
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
I think u off ur WIFI in phone.

Categories

Resources