Code example for BluetoothAdapter

Methods: disable, getState, setDiscoverableTimeout

0
            } 
 
            if (action.equals("com.android.samsungtest.BluetoothRfTestOff")) { 
                Toast.makeText(mContext, "Exit Bluetooth RF test mode", Toast.LENGTH_SHORT).show(); 
 
                if (mAdapter.getState() == BluetoothAdapter.STATE_ON) { 
                    mAdapter.disable(); 
                } 
                finish(); 
            } 
        } 
    }; 
         
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bluetooth_rf_test);
        if (DBG) Log.d(TAG, "OnCreate()");
 
        findViewById(R.id.ButtonExitBtRfTest).setOnClickListener(this);
         
        mContext = this;
         
        mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
        mContext.registerReceiver(mReceiver, mIntentFilter);
 
        final IntentFilter mIntentFilter2 = new IntentFilter();      
        mIntentFilter2.addAction("com.android.samsungtest.BluetoothRfTestOff");
        mContext.registerReceiver(mReceiver, mIntentFilter2);
         
        mAdapter = (BluetoothAdapter) BluetoothAdapter.getDefaultAdapter();
 
        if (mAdapter.getState() == BluetoothAdapter.STATE_OFF) {
            mAdapter.enable();
        } else if (mAdapter.getState() == BluetoothAdapter.STATE_ON) {
            onEnterBtRfTest(); 
        } 
    } 
 
    private void onEnterBtRfTest() { 
        if (DBG) Log.d(TAG, "Enter Bluetooth RF test mode");
        try { 
            Thread.sleep(1000);
        } catch (InterruptedException e) {}
        mAdapter.setDiscoverableTimeout(0);
        SystemProperties.set("ctl.start", "bt_dut_cmd"); 
        Toast.makeText(mContext, "Enter Bluetooth RF test mode", Toast.LENGTH_SHORT).show();
    } 
 
    public void onClick(View v) {