-1

So my question is fairly simple, but I cannot find a solution of the entire idea. Running Android App in background should be achievable with Background Service . However, I am not sure how to make "wake up" the service by a specific button press combination.

DUMMY EXAMPLE:

// My app is installed and launched on the device and is running in background since it got installed

void onCorrectButtonCombinationPressed(){
     startActivity(someIntent);
}

How to achieve the above scenario ?

Thanks for suggestions and I apologize if there is something silly that I missed out, because to me it sounds easy to do, but I am struggling to figure it out..

David Kasabji
  • 1,049
  • 3
  • 15
  • 32
  • By ***specific button press combinations*** do you mean buttons in the phone hardware? Like for example when taking a screenshot of the phone (Power Button + Vol Up/Down) ? – AL. Mar 09 '16 at 01:15
  • @sept exactly that Sept, I want to take screenshot but with my own button combination. that is my Project goal. – David Kasabji Mar 09 '16 at 11:37
  • I see. I have no actual experience regarding this but I'll try to check it out. For the meantime, have you seen this post yet -- http://stackoverflow.com/questions/12462944/how-to-take-a-screenshot-of-other-app-programmatically-without-root-permission – AL. Mar 09 '16 at 12:45
  • @sept i have checked the link and sample code from Google, but it seems that the app is only displaying the phone's screen within the App itself. If I try to go outside the app, it does not trigger anything. Am I missing something ? How can I take screenshot with sample, without having the app in front-end ? – David Kasabji Mar 13 '16 at 18:53
  • I've been looking around SO and found this 2 posts that may be useful. In regards with the app *waking up* when it is currently in the background, check this [answer](http://stackoverflow.com/a/12793599/4625829), and for the programatically taking a screenshot, check [this](http://stackoverflow.com/questions/20136121/android-how-to-take-screenshot-programatically). – AL. Mar 13 '16 at 23:41

1 Answers1

-1

That depends on what you mean by a "specific button press combination"

If you want to detect clicks or button presses from your own activity, then handle it within its respective view through standard event handlers.

if you want to detect clicks or button presses from OTHER activities, give up! There is no means by which you can achieve this through (standard) methods. If you root your device you'll have more power to do something like this, but I did some deep research and found no other ways. The reason for this is because imagine how easy it would be to steal information from activities if you could intercept events being sent to it.

I asked a question the other day that may give you further information.

Community
  • 1
  • 1
Shane Duffy
  • 1,117
  • 8
  • 18
  • Hi Shane. So what I want to do is, what I wrote in above comment. With some button combination, I would like to take Screenshot and then use it in my way. – David Kasabji Mar 09 '16 at 11:36
  • You cannot take a screenshot of a foreign application, as it violates the rules of Android. You could probably do so if you rooted your device, but not otherwise. – Shane Duffy Mar 09 '16 at 17:06