Mah*_*esh 25 settings android android-intent
我想打开按钮点击的蓝牙设置,如图所示
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);
}
});
Run Code Online (Sandbox Code Playgroud)
Ewo*_*oks 53
也许我错过了一些东西,但这不是更简单的未来证明解决方案吗
Intent intentOpenBluetoothSettings = new Intent();
intentOpenBluetoothSettings.setAction(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intentOpenBluetoothSettings);
Run Code Online (Sandbox Code Playgroud)
绝对不可能"删除"其他设置.在手机上只显示一类设置.在平板电脑上,由于一些额外的空间,设置以主 - 细节布局显示,因此平板电脑屏幕的一半以上没有空白空间.这就是Android的设计方式,只需编写一个无法更改的应用程序.
正如@zelanix所建议的那样BLUETOOTH_ADMIN,清单中的权限是必需的.
Aj *_* 27 21
我想你应该尝试这个更简单的一个:
startActivity(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS));
Run Code Online (Sandbox Code Playgroud)
ρяσ*_*я K 16
使用
ComponentName cn = new ComponentName("com.android.settings",
"com.android.settings.bluetooth.BluetoothSettings");
Run Code Online (Sandbox Code Playgroud)
代替
final ComponentName cn = new ComponentName("com.android.settings",
"com.android.settings.bluetoothSettings");
Run Code Online (Sandbox Code Playgroud)
启动BluetoothSettings设置
| 归档时间: |
|
| 查看次数: |
30991 次 |
| 最近记录: |