android - Samsung Galaxy XCover/Active button -


the galaxy s4/s5/s6 active , galaxy xcover models have hardware button. in settings user can choose app button should open when pressed.

i'm developing app targeted @ galaxy xcover 3. when user opens app first time, want ask user if want let hardware button open app.

i have tried register broadcastreceiver on "camera button" event, doesn't work.

does know how achieve result?

i had same problem , found solution.

use code below find 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 final int keycode.

final int active_button = 1015; 

and last write onkeydown event.

@override public boolean onkeydown(int keycode, keyevent event){     switch(keycode){         case active_button:             //your action here             return true;     } } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -