-2

how to make an activity in specific app(security app) started when pressing (menu or any other of the device buttons), what i should do?, i'm already have BroadcastReceiver in my app(to read SMS). I'm new to android, so from where i should start? Please help me.

Edit: In my phone(Samsung) if i press too long on menu button one of google apps started(launched).

Yousif
  • 527
  • 5
  • 23
  • I don't think that is a good idea.. The purpose of home button is to bring you home (the launcher). This would result in a activity that user wouldn't generally expect. – Kuba Spatny Sep 24 '13 at 16:48
  • I second Kuba comment, please don't do that since it's not a good idea. Home button is there to bring the user home or (i.e. Samsung devices) to open the task manager after a long press. Consider also, if a manufacturer will implement a behaviour like yours, unexpected things will happen. – fasteque Sep 24 '13 at 18:53
  • @KubaSpatny this app i'm developing for security purposes, so what i should do to make it started when pressing on home button(see the post) even when the app is not running in background. thanx – Yousif Sep 24 '13 at 19:44
  • @fasteque i don't want to disable home button functions, in my post i said (e.g like 3 times), and also said other buttons are fine (like power button). thanx – Yousif Sep 24 '13 at 19:48

1 Answers1

0

According to the official Android documentation (http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME): Key code constant: Home key. This key is handled by the framework and is never delivered to applications.

fasteque
  • 4,309
  • 8
  • 38
  • 50
  • Deer fasteque, if home button isn't possible what about power button(even if back)? all i want is to have a guidence to how start an app when pressing one of the device buttons when that app is off. and see the edit in the post. thanx – Yousif Sep 24 '13 at 21:02
  • I suggest you to rethink/redesign your app without listening to those keys (http://stackoverflow.com/questions/12353647/keycode-power-only-dispatched-on-long-press) because there are serious security and usability issues. – fasteque Sep 24 '13 at 21:26