jump To Open Bluetooth - Android android.bluetooth

Android examples for android.bluetooth:Bluetooth

Description

jump To Open Bluetooth

Demo Code

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;

public class Main {

  public static void jumpToOpenBluetooth(Context context) {
    if (isThisMahionSupportBluetooth() && !isBluetoothHadOpen()) {
      Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
      context.startActivity(intent);/*  ww  w .  java  2  s  .  c  om*/
    }
  }

  public static boolean isThisMahionSupportBluetooth() {
    BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
    if (null != ba) {
      return true;
    }
    return false;
  }

  public static boolean isBluetoothHadOpen() {
    if (isThisMahionSupportBluetooth()) {
      BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter();
      if (ba.isEnabled()) {
        return true;
      }
    }
    return false;
  }

}

Related Tutorials