Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get current running foreground application (package) for all available OS?

Tags:

android

mdm

I know, too many questions already raised on this topic but, that are not supported in all OS / devices

Question

  1. Is there any way to get current running foreground application (package) for all available OS?
  2. How AppLock works (how it detects any app launches)?

What I have tried (but failed)

  1. How do I detect if an android app is launched? - Google has disabled in Android L.
  2. How to use UsageStatsManager? - android.permission.GET_TASKS is depricated.
  3. How to make my app a device owner? - Cannot execute this command pro-grammatically.
  4. ?
  5. Knox Standard SDK

What I want

  • User should not able to access black listed app. My app should launch in front of black listed app (as same as AppLock does)
  • User can only access apps, that are white listed.
  • I have tried many more solution, but not able to get perfect solution that can work in all available OS / devices.
  • I want solution programmatically / free / for each device and OS
like image 937
Dhruv Avatar asked Nov 07 '22 12:11

Dhruv


1 Answers

You can have 2 approaches to this that may be acceptable, otherwise you are probably out of luck.

1) Make your app the "launcher" app. Users will then be interacting with your app in order to launch apps in general. Notification based launches and other types of interactions you may not be able to track, but I have not tried.

2) Make your app "pretend" to be a launcher app. After it launches, it displays a launcher type screen. You then have to handle attempts to press "home" by checking if your app is in the background and bringing it into foreground if it is. This is not an easy task - it's likely you will have bugs, etc. but it seems possible (I only know that determining if your app is "in the background" can be tricky because dialog boxes and notifications can take the foreground, but you do not want to dismiss those (most of the time I assume).

Good luck!

like image 177
Jim Avatar answered Dec 08 '22 14:12

Jim