Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Samsung Galaxy XCover/Active button

the Galaxy S4/S5/S6 Active and the Galaxy XCover models have this extra hardware button. In the settings the user can choose which app the button should open when it is pressed.

I'm developing an app that is specifically targeted at the Galaxy XCover 3. When the user opens the app for the first time, I want to ask the user if they want to let the hardware button open my app.

I have tried to register a broadcastreceiver on the "Camera button" event, but this doesn't work.

Does anyone know how I could achieve this result?

like image 947
Mark Buikema Avatar asked Oct 22 '15 12:10

Mark Buikema


People also ask

What does the XCover button do?

By pushing the XCover key, a construction worker can initiate push-to-talk communications with a colleague, then long-press to launch the flashlight to peer into a dark crawl space.

How do I program the buttons on my Samsung phone?

You can remap the Side key to open any app of your choice. Navigate to and open Settings, tap Advanced features, and then tap Side key. From here, you can select your desired settings.

How do I force restart XCover pro?

Press and hold the Volume down and Side buttons, then select Restart > Restart. Note: If you are unable to access the screen to 'Restart' the device or if it becomes unresponsive, press and hold the Volume down and Side buttons simultaneously for 10 seconds, until the device restarts.


1 Answers

I had the same problem and found a solution.

Use the code below to find the keycode.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    super.onKeyDown(keyCode, event);
    System.out.println("keycode -->" +keyCode);
    System.out.println("Key event -->" + event );
    return false;
}

Then make a final int with the keycode.

final int ACTIVE_BUTTON = 1015;

And last write your onKeyDown event.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
    switch(keyCode){
        case ACTIVE_BUTTON:
            //your action here
            return true;
    }
}
like image 78
Maarten Lammers Avatar answered Sep 18 '22 23:09

Maarten Lammers