Hello we are using bluetooth in Android.
When we turn on bluetooth it give us default dialog "An app wants to turn on Bluetooth" with Deny and Allow buttons. With this message a blue line is shown behind that dialog which is nothing but a text "Bluetooth Permission". Can we hide or remove this message behind the dialog. I have attached screenshots of the page.
Here is the code Snippet
if (!mBluetoothAdapter.isEnabled()) {
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
}
Related
How change VPN pop up dialog permissions?
I start vpn pop up dialog permission like this:
Intent intent = VpnService.prepare(this);
if (intent != null) {
VpnStatus.updateStateString("USER_VPN_PERMISSION", "",
R.string.state_user_vpn_permission,
VpnStatus.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT);
try {
startActivityForResult(intent, START_VPN_PROFILE);
}
}
Here is the result:
Nice, but how I can change text. I want to set my custom text.
Is it possible?
And second question:
Is it possible to show message always on English. Even I change language on device?
I am new in android development.
I have a BluetoothAdapter, if bluetooth not enabled automatically asks the window for allow/deny. It is woking fine but, when tap on outside of the alert will dismiss the alert. How can I disable the dismissal of the alert when tap out side of the alert window.
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, BluetoothState.REQUEST_ENABLE_BT);
What you have is an Activity, so you should call setFinishOnTouchOutside(false) from your activity if you want to keep your dialog open when the background activity is clicked.
With the following code you can pop up a window with bluetooth acces request:
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
The output of the code is the following image:
Is it possible to change the message (so not "An app wants to turn on Bluetooth", but something like "Hey can you please turn on Bluetooth?"
You should create your own dialog with your own message and then call
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.enable();
And do not forget to declare the BLUETOOTH_ADMIN permission in your manifest.
Anyway, this operation is discouraged... The enable() method is provided only for applications that include a user interface for changing system settings, such as a "power manager" app.
No, this is build-in Android functionality, so you would have to make a custom dialog which asks the question the way you want.
Then you would enable or disable Bluetooth programmatically based on what the users choice was.
I am trying to use BluetoothAdapter with ACTION_REQUEST_DISCOVERABLE to discover my phone to other users according to this:
testIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivity(testIntent);
I get the dialog box of Bluetooth Permission Request, but for some reason I can't see it on my activity. I can see it only when I exit this program. I want to override the menu in that dialog.
Can I do it , if so , how can I change it ? And why can't I see it on the activity I am in it ?
I am trying to get my Activity to enable Bluetooth with the Android 2.0.1 SDK, I am using some code straight from the documentation here: http://developer.android.com/guide/topics/wireless/bluetooth.html
Which is:
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
I get an error at the REQUEST_ENABLE_BT part where Eclipse says it cannot be resolved. What am I doing wrong?
The REQUEST_ENABLE_BT part is a request code that you should handle in your onActivityResult method. In that method you'll be notified whether or not enabling Bluetooth was successful.
In that code snippet they didn't show the definition of it, but it's just a constant integer so you can set it to any value you like.
See the documentation for startActivityForResult for more info about getting results back from activity launches.