Code example for Intent

Methods: putExtrasetAction

0
        registerReceiver(mReceiver, filter);
        addMsg("Initialized"); 
    } 
 
    void requestPermission(boolean enableOnly) {
        Intent i = new Intent();
        if (enableOnly) {
            addMsg("Starting activity to enable bt"); 
            i.setAction(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        } else { 
            addMsg("Starting activity to enable bt + discovery"); 
            i.setAction(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
            // Discoverability duration toggles between 20 seconds and no timeout. 
            int timeout = (mDiscoveryWithTimeout ? 20 : 0);
            i.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, timeout);
            mDiscoveryWithTimeout = !mDiscoveryWithTimeout;
        } 
        startActivityForResult(i, 1);
    } 
 
    @Override