简体   繁体   中英

Android is app still showing Bluetooth connect permission dialog

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... :/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM