I want to record what application is being used by the user at every time. I can write a program to save the processes running on the phone, but I want to know which one is the one that the user is interacting with.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t know if this is what Chris was referring to in the comment, and I don’t know how reliable it is, but you can iterate through the list returned by ActivityManager#getRunningAppProcesses () :
Then, check for the importance field of each
ActivityManager.RunningAppProcessInfo:You may have a service polling every 30 seconds or so and log those values.
(BTW, you want to look for those
IMPORTANCE_FOREGROUNDandIMPORTANCE_VISIBLE)