Permissions, apps running and backcompatibility in android 6.0 vs 4.2

53 views Asked by At

I have a problem and I really don't know how to solve it. It is about an application running on an Android tablet.

The application has to:

  • Check if a given third party application is running AND on foreground (active);
  • Install .apk files (i.e. launching them from a temp folder);
  • Delete the same .apk files;
  • Run on old tablets with Android down to 4.0.3 (Ice Cream Sandwich) as well as on new tablets with Android 6.0 (Marshmallow).

The problem comes from the change in permission protocol between API level 22 and 23. I don't see how to request permissions at run time since requestPermissions() was added in level 24. So I supposed I could grant permission manually before launching the application but I cannot find how (if it is even possible).

At present time, I call UsageStatsManager.queryUsageStats() and, as expected, it returns an empty list (using my Marshmallow tablet).

If someone could help me, I would greatly appreciate.

0

There are 0 answers