@SuppressLint("MissingPermission") // We check before this is called
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gatt_services);

        final Intent intent = getIntent();
        mDevice = intent.getParcelableExtra(EXTRA_DEVICE);
        view = new View(this);

        // Sets up UI references.
        ((TextView) findViewById(R.id.device_address)).setText(mDevice.getAddress());
        view.setListClickListener(servicesListClickListner);

        getSupportActionBar().setTitle(mDevice.getName());
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mExporter = new Exporter(this);

        final Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
    }
For a given BLE device, this Activity provides the user interface to connect, display data,
and display GATT services and characteristics supported by the device.  The Activity
communicates with {@code BluetoothLeService}, which in turn interacts with the
Bluetooth LE API.
sample_app/src/main/java/uk/co/alt236/btlescan/ui/control/DeviceControlActivity.java