Example usage for android.bluetooth BluetoothAdapter getDefaultAdapter

List of usage examples for android.bluetooth BluetoothAdapter getDefaultAdapter

Introduction

In this page you can find the example usage for android.bluetooth BluetoothAdapter getDefaultAdapter.

Prototype

public static synchronized BluetoothAdapter getDefaultAdapter() 

Source Link

Document

Get a handle to the default local Bluetooth adapter.

Usage

From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java

final static public void setBluetoothOff(TaskManagerParms taskMgrParms, EnvironmentParms envParms,
        CommonUtilities util, TaskResponse task_response, ActionResponse ar) {
    if (BluetoothAdapter.getDefaultAdapter() != null) {
        if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
            if (envParms.settingDebugLevel >= 1)
                util.addDebugMsg(1, "I", "setBluetoothOff Bluetooth off");
            BluetoothAdapter.getDefaultAdapter().disable();
            ar.action_resp = ActionResponse.ACTION_SUCCESS;
            ar.resp_msg_text = "";
        } else {/*from   w w  w . j av  a  2s.com*/
            ar.action_resp = ActionResponse.ACTION_WARNING;
            ar.resp_msg_text = "Bluetooth already off";
        }
    } else {
        if (envParms.settingDebugLevel >= 1)
            util.addDebugMsg(1, "I", "setBluetoothOff BluetoothAdapter not available, Bluetooth off ignored");
        ar.action_resp = ActionResponse.ACTION_WARNING;
        ar.resp_msg_text = "Bluetooth not available";
    }
}

From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java

final static public void setBluetoothOn(TaskManagerParms taskMgrParms, EnvironmentParms envParms,
        CommonUtilities util, TaskResponse task_response, ActionResponse ar) {
    if (BluetoothAdapter.getDefaultAdapter() != null) {
        if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
            if (envParms.settingDebugLevel >= 1)
                util.addDebugMsg(1, "I", "setBluetoothOn Bluetooth on");
            BluetoothAdapter.getDefaultAdapter().enable();
            ar.action_resp = ActionResponse.ACTION_SUCCESS;
            ar.resp_msg_text = "";
        } else {//ww  w . j a va  2  s. co m
            ar.action_resp = ActionResponse.ACTION_WARNING;
            ar.resp_msg_text = "Bluetooth already on";
        }
    } else {
        if (envParms.settingDebugLevel >= 1)
            util.addDebugMsg(1, "I", "setBluetoothOn BluetoothAdapter not available, Bluetooth on ignored");
        ar.action_resp = ActionResponse.ACTION_WARNING;
        ar.resp_msg_text = "Bluetooth not available";
    }
}

From source file:com.rfo.basic.Run.java

private void InitRunVars() { // init vars needed for Run
    clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    mInterpreter = null; // reference to Interpreter Thread
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void loadPreferenceDataBase() {
    //get the default values
    //List<String> defaults = OptionsScreen.loadDefaults();

    String uniqueID = "";

    //get the IMEI number
    try {/* w w w. j a  va 2 s  .  co  m*/
        TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        if (tm != null)
            uniqueID = tm.getDeviceId();
        if (uniqueID == null || uniqueID.length() == 0) {
            WifiManager wifimanager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
            if (wifimanager != null)
                uniqueID = wifimanager.getConnectionInfo().getMacAddress();
        }
        if (uniqueID == null)
            uniqueID = BluetoothAdapter.getDefaultAdapter().getAddress();
        if (uniqueID == null)
            uniqueID = "123456789";
    } catch (Exception e) {
        uniqueID = "987654321";
    }

    String uniqueIdDB = Utility.getUniqueNumber(uniqueID);

    //get the type of phone  (GSM,CDMA) and put into constants
    GTConstants.PHONE_TYPE = getPhoneType();

    //Load into new database 
    preferenceDB.open();

    id = preferenceDB.insertRecord(GTConstants.LOCATIONUPDATESINTERVAL,
            GTConstants.LOCATIONUPDATEDISTANCEINTERVAL, GTConstants.SERVERIP,
            String.valueOf(GTConstants.SERVERPORT), GTConstants.PANIC_NUMBER, uniqueIdDB,
            String.valueOf(GTConstants.ACCELEROMETER_SPEED), GTConstants.LICENSE_ID, GTConstants.PHONE_TYPE,
            GTConstants.REGISTRATION);

    preferenceDB.close();

    //load into constants
    preferenceDB.open();
    cursor = preferenceDB.getRecordByRowID("1");

    saveInConstants(cursor);

    cursor.close();
    preferenceDB.close();

}