如何自动化用户对Android用户权限对话框的响应?
我正在编写一个在Android设备上运行蓝牙的测试应用程序。我希望我的测试应用程序能够使设备可发现。简单的搜索可以让我找到如下内容:如何自动化用户对Android用户权限对话框的响应?,android,android-intent,ui-automation,android-permissions,android-bluetooth,Android,Android Intent,Ui Automation,Android Permissions,Android Bluetooth,我正在编写一个在Android设备上运行蓝牙的测试应用程序。我希望我的测试应用程序能够使设备可发现。简单的搜索可以让我找到如下内容: Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(dis
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
此方法的问题是,它将带来“用户权限”对话框
如何在“权限”对话框中自动按“是”或“否”?嗯,我有类似的经验,下面是我的建议
onView(allOf(withText("Yes"), withParent(/* The features of the dialog */))).perform(click());
您是否在清单中声明了权限?只是想确定一下。我从未在我的应用程序中使用过蓝牙。我确实拥有所有的BT权限
和
那么蓝牙呢?这允许您在无需用户交互的情况下配对蓝牙设备。这是一项安全功能。您可能找不到在非根设备上绕过它的方法。BLUETOOTH\u PRIVILEGED将允许您访问非公共API。你知道一个非公开的API来改变设备的可发现性吗?据我所知,公共API中没有。