How to detect click event of connected Bluetooth peripheral device (Selfie stick)?

Vikasdeep Singh

I have Selfie stick connected to my phone. I am able to find device ID using below code:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
        this.registerReceiver(mReceiver, filter);
}

  //The BroadcastReceiver that listens for bluetooth broadcasts
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
                //Device is now connected
                Toast.makeText(getApplicationContext(), "ACTION_ACL_CONNECTED" + device, Toast.LENGTH_LONG).show();
            }
         }
    };

My question is how I can detect button press/click event of this connected peripheral device?

Help in form of code snippet/tutorial/comments is highly appreciable. Thanks!!!

EDIT:

When I press button of Selfie stick Volume + button listen to the event

Vikasdeep Singh

I found the answer. It was very simple. Just override onKeyDown() method of Activity.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub
    return super.onKeyDown(keyCode, event);
}

Here keyCode is the event name returned.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can a JavaScript app detect if a Leap Motion device is connected

分類Dev

ps3 bluetooth remote connected as linux input device has only one event type on 13.10

分類Dev

On my Bluetooth LE device, can I change an attribute of a characteristic on a peripheral device?

分類Dev

How to detect volume up button click event using javascript?

分類Dev

How to detect a click on a polyline

分類Dev

How to detect if Chromecast is already connected on Android Sender?

分類Dev

How detect the devices connected to wif network

分類Dev

How does an AWS IoT device show as "connected"

分類Dev

RxBluetoothKit: How to subscribe to Bluetooth state + Peripheral connection state and Write/Notify characteristics at same time?

分類Dev

How to programmatically pair and connect a HID bluetooth device(Bluetooth Keyboard) on Android

分類Dev

How to detect a click on the CheckBox in the TListView

分類Dev

How to reliably detect if an external keyboard is connected on iOS 9?

分類Dev

How to detect slide event direction in Bootstrap carousel

分類Dev

Connecting to a bluetooth device programmatically

分類Dev

How to use BLE OBDII Peripheral

分類Dev

How can we programmatically detect which iOS version is device running on?

分類Dev

How to make pulseaudio and ubuntu detect the same audio device as alsa driver

分類Dev

Detect rings/circuits of connected voxels

分類Dev

how to simulate the click event on the facebook share button

分類Dev

How to programmatically issue a click event on Android

分類Dev

How to add value to an array on click event

分類Dev

how to create the click event in sidebar navigation

分類Dev

How to pass or bubble a click event to another layer?

分類Dev

How to attach click event to a css styled checkbox

分類Dev

How to consume click event in view hierarchy

分類Dev

How to get Click event on MvxLinearLayout items\childeren?

分類Dev

How to disable the click event for the customized checkbox

分類Dev

How to handle webview click event in android studio?

分類Dev

how to catch the click event on a specific mesh in a group

Related 関連記事

  1. 1

    How can a JavaScript app detect if a Leap Motion device is connected

  2. 2

    ps3 bluetooth remote connected as linux input device has only one event type on 13.10

  3. 3

    On my Bluetooth LE device, can I change an attribute of a characteristic on a peripheral device?

  4. 4

    How to detect volume up button click event using javascript?

  5. 5

    How to detect a click on a polyline

  6. 6

    How to detect if Chromecast is already connected on Android Sender?

  7. 7

    How detect the devices connected to wif network

  8. 8

    How does an AWS IoT device show as "connected"

  9. 9

    RxBluetoothKit: How to subscribe to Bluetooth state + Peripheral connection state and Write/Notify characteristics at same time?

  10. 10

    How to programmatically pair and connect a HID bluetooth device(Bluetooth Keyboard) on Android

  11. 11

    How to detect a click on the CheckBox in the TListView

  12. 12

    How to reliably detect if an external keyboard is connected on iOS 9?

  13. 13

    How to detect slide event direction in Bootstrap carousel

  14. 14

    Connecting to a bluetooth device programmatically

  15. 15

    How to use BLE OBDII Peripheral

  16. 16

    How can we programmatically detect which iOS version is device running on?

  17. 17

    How to make pulseaudio and ubuntu detect the same audio device as alsa driver

  18. 18

    Detect rings/circuits of connected voxels

  19. 19

    how to simulate the click event on the facebook share button

  20. 20

    How to programmatically issue a click event on Android

  21. 21

    How to add value to an array on click event

  22. 22

    how to create the click event in sidebar navigation

  23. 23

    How to pass or bubble a click event to another layer?

  24. 24

    How to attach click event to a css styled checkbox

  25. 25

    How to consume click event in view hierarchy

  26. 26

    How to get Click event on MvxLinearLayout items\childeren?

  27. 27

    How to disable the click event for the customized checkbox

  28. 28

    How to handle webview click event in android studio?

  29. 29

    how to catch the click event on a specific mesh in a group

ホットタグ

アーカイブ