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);
}
});
adb shell am start -a android.settings.BLUETOOTH_SETTINGS
use
instead of
to launch BluetoothSettings settings
I think you should try this easier one :
Maybe I missed something but isn't this simpler future proof solution?
It is definitely not possible to "remove" the other settings. On phones just one category of settings is shown. On tablets, because of some extra space, settings are shown in master-detail layout so there is no empty space on more the half of the tablet screen. This is how Android is designed and just by writing one app that can not be changed.
As suggested by @zelanix the
BLUETOOTH_ADMIN
permission in manifest is required.If you want to open up the scan dialog (without leaving your app).