First of all, please note that this question is not same as all the "android foreground app" questions I found on SO, please read on :-)
I am trying to write an android app for my own use, using golang, without using android-sdk or ndk (this is the KEY point). It is pretty simple, just use golang to write a http service, compile it for arm cpu and voila my app is running and can be access by simply visit http://localhost.
For the purpose of my app, I need to know the currently running foreground application, to define it precisely:
1) foreground application is the application that occupies the screen, or has an "activity" what-so-ever (forgive me I am not an android developer).
2) anything that that is depended by the foreground application (e.g. services) is NOT what I am interested in.
3) if the phone is LOCKED/screen turned off, I want the solution to tell me there is NO foreground app.
And since I do not use anything android, just treat the phone as a linux machine, I want the solution to use native linux ways, e.g. by inspect /proc, or by calling any installed android command line tool (including sending messages via these command line tools), but NOT using any SDK/NDK way so that I have to use java or incorporate these thing into my app.
from Android : How to get the process id of the foreground app
No comments:
Post a Comment