Android 14的Google Pixel设备如何通过Intent打开原生蓝牙设置?
在Android 14的Google Pixel设备上打开原生蓝牙设置界面的解决方案
在Android 14的Google Pixel设备上,调用Settings.ACTION_BLUETOOTH_SETTINGS或执行adb命令adb shell am start -a android.settings.BLUETOOTH_SETTINGS会跳转到“已连接设备”页面,而非独立的蓝牙设置界面,这是Google对Android 14设置界面的整合调整导致的。以下是可行的解决方案:
方法一:直接启动Pixel设置的蓝牙专属组件
通过指定Google设置应用的具体组件,可直接打开蓝牙设置页面:
代码实现
Intent intent = new Intent(); // 指定Pixel设置应用的蓝牙Activity组件 intent.setComponent(new ComponentName( "com.google.android.settings", "com.google.android.settings.bluetooth.BluetoothSettings" )); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
adb命令验证
adb shell am start -n com.google.android.settings/.bluetooth.BluetoothSettings
方法二:兼容性适配方案
如果应用需要适配多品牌设备,可通过设备厂商和系统版本判断,针对性选择启动方式:
Intent intent; // 判断是否为Android 14及以上的Google Pixel设备 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && "Google".equals(Build.MANUFACTURER)) { // Pixel Android 14+专属逻辑 intent = new Intent(); intent.setComponent(new ComponentName( "com.google.android.settings", "com.google.android.settings.bluetooth.BluetoothSettings" )); } else { // 通用设备的标准启动方式 intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); } intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
注意事项
- 组件名
com.google.android.settings.bluetooth.BluetoothSettings是当前Android 14版本Pixel设备的有效路径,未来系统更新可能发生变化,需定期测试适配。 - 该方案仅针对Google Pixel设备,其他品牌设备仍可使用标准的
Settings.ACTION_BLUETOOTH_SETTINGS动作。
内容的提问来源于stack exchange,提问作者Stefan
相关产品推荐
相关产品推荐

