简体   繁体   English

Android是应用程序仍然显示蓝牙连接权限对话框

[英]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.我在应用程序中摆弄 Java 中的蓝牙连接,完成后,我从 Android 清单中删除了所有初始化代码和权限。 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.即使从 Android Studio 运行,所有其他物理设备也不会显示此对话框。 The dialog shows before the MainActivity even loads, and then promptly crashes the app.该对话框在 MainActivity 加载之前显示,然后立即使应用程序崩溃。 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... :/这不是一个问题,而是一个好奇心,但如果我将应用程序发布到 Google Play 并且用户必须处理这个盒子,这无疑会令人不安......:/

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.因此,如果您不想看到它,请删除此权限请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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