i want to develop an app locker. for that i want recently opened app to check if it is secured or not and then pop up my password activity in front of it AND recently closed app to reset the flag(i.e if next time it's opened,password activity comes again). Do anybody have some better approach how can i do this??
Asked
Active
Viewed 595 times
1 Answers
0
What you probably need is ActivityManager.getRunningTasks
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTasks = am.getRunningTasks();
You create a service that periodically looks up the running tasks, identifies the new tasks and checks their package using RunningTaskInfo.baseActivity.getPackageName(). Since you know the PID, you can kill the task.
PS. This approach is not 100% proof, because your service can be disabled or uninstalled. Secondly, it wastes memory and battery :)

cyanide
- 3,885
- 3
- 25
- 33
-
So you mean all app locking applications waste cup and battery ?? – Usman Riaz Aug 05 '14 at 09:05
-
And can we kill the task ?? http://stackoverflow.com/questions/4921244/android-task-kill – Usman Riaz Aug 05 '14 at 09:09