如何打开蓝牙设置活动编程? [英] How do I open the Bluetooth Settings Activity programmatically?
本文介绍了如何打开蓝牙设置活动编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打开按钮点击蓝牙设置 这样看图片
I want to open bluetooth settings on button click like this see image
HomeActivity.java
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.bluetoothSettings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity( intent);
}
});
推荐答案
使用
use
而不是
final ComponentName cn = new ComponentName("com.android.settings",
"com.android.settings.bluetoothSettings");
要推出BluetoothSettings设置
to launch BluetoothSettings settings
这篇关于如何打开蓝牙设置活动编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文