I was fiddling around with Bluetooth connections in Java in an app, and once I was done, I removed all the initialization code, and the permissions from the Android manifest. Yet every time I start the app, it shows this:
My manifest contains no bluetooth permissions, and my code has no references, I have deleted all the files associated with it. I would like to know why this occurs. Additionally, perhaps more strangely, this only happens on one physical device which I tested the bluetooth connectivity on. All other physical devices do not show this dialog even on a run from Android Studio. The dialog shows before the MainActivity even loads, and then promptly crashes the app. Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application
android:allowBackup="true"
android:icon="@mipmap/app_icon_large_foreground"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
</activity>
<activity
android:name=".splashScreen"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".settings_activity"
android:label="Settings"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".secondActivity"
android:label="SecondActivity"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".MainActivity"
android:label="MyApp"
android:windowSoftInputMode="stateAlwaysHidden" />
</application>
</manifest>
There is no reference to bluetooth anywhere in ANY of my code! Why does this dialog continue to appear? Is it something to do with the app's permissions cache? Except I've uninstalled and reset the apps cache and it shows "No Permissions" in the App Permissions for the app.
This is less of a problem and more of a curiosity, but is undoubtedly troubling if I publish an app to Google Play and the users have to deal with this box... :/
CodePudding user response:
You must look in your project for something like this:
if (ContextCompat.checkSelfPermission(requestingActivity,
permission) != PackageManager.PERMISSION_GRANTED) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(
requestingActivity, permission)) {
ActivityCompat.requestPermissions(requestingActivity,
new String[] { permission }, requestCode);
}
}
that opens this permission dialog. So, if you don't want to see it remove this permission request.