android-lib/src/main/java/io/v/android/impl/google/discovery/plugins/ble/BluetoothAdvertiser.java
/**
     * Add a service to the Bluetooth advertiser.
     */
Add a service to the Bluetooth advertiser.
Add a service to the Bluetooth advertiser .
synchronized void addService(UUID uuid, int discoverableDurationInSec) {
        mServices.add(uuid);
        if (discoverableDurationInSec <= 0) {
            return;
        }
        if (mRfcommListener == null) {
            mRfcommListener = new RfcommListener();
            mRfcommListener.start();
        }
        if (mBluetoothAdapter.getScanMode()
                == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
            Log.w(TAG, "already in discoverable mode");
            return;
        }
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(
                BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, discoverableDurationInSec);
        discoverableIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(discoverableIntent);
    }
synchronized void addService ( UUID uuid , int discoverableDurationInSec ) { mServices . add ( uuid ) ; if ( discoverableDurationInSec <= 0 ) { return ; } if ( mRfcommListener == null ) { mRfcommListener = new RfcommListener ( ) ; mRfcommListener . start ( ) ; } if ( mBluetoothAdapter . getScanMode ( ) == BluetoothAdapter . SCAN_MODE_CONNECTABLE_DISCOVERABLE ) { Log . w ( TAG , "already in discoverable mode" ) ; return ; } Intent discoverableIntent = new Intent ( BluetoothAdapter . ACTION_REQUEST_DISCOVERABLE ) ; discoverableIntent . putExtra ( BluetoothAdapter . EXTRA_DISCOVERABLE_DURATION , discoverableDurationInSec ) ; discoverableIntent . setFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; mContext . startActivity ( discoverableIntent ) ; }
Add a service to the Bluetooth advertiser.
Add a service to the Bluetooth advertiser .
// Make it discoverable if not already in discoverable mode.