If you wish to turn on Bluetooth in android when your app run then use the code written below .This code will ask you to turn on your mobile Bluetooth if the Bluetooth is off.
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled())
{
Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);
Toast.makeText(getApplicationContext(),"Turned on",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Already on", Toast.LENGTH_LONG).show();
}
0 Comment(s)