I would like to be able to start an activity or service and get the PID of that process as quickly as possible, immediately would be the best case scenario. Do I have any options other than browsing the /proc directory, which then leads to a variable-amount-of-time race condition between the time the activity/service is launched and the time it takes me to find what I want in the proc directory and begin observing?
In the Start menu search bar, search for command prompt and select Run as administrator. Type tasklist. Press Enter. Command Prompt will now display the PID for the running processes.
A started service can use the startForeground(int, android. app. Notification) API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory.
pid = process ID. uid = user ID of the application that owns that process. gid = group IDs of the application that owns that process.
I think you'd need to use ActivityManager: see http://developer.android.com/reference/android/app/ActivityManager.RunningAppProcessInfo.html for the process info. You could:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With