0

I clone this url to check app lock. ToolWizAppLock https://github.com/Toolwiz/ToolWizAppLock

But Its working only for below 19 Api(Android version 4.4.4) and Not working in Above 20 API.

What Should i do to make work on all Android version above 5.0?

1 Answers1

0

activityManager.getRunningTasks(1).get(0).topActivity.getPackageName(); activityManager.getRunningTasks(1).get(0).topActivity.getClassName();

no more available of android version 20 or abouve so you need to change this using below code

if (Build.VERSION.SDK_INT > 20) {
                    mPackageName = activityManager.getRunningAppProcesses().get(0).processName;
                    mClassName = activityManager.getRunningAppProcesses().get(0).getClass().getName();
                } else {
                    mPackageName = activityManager.getRunningTasks(1).get(0).topActivity.getPackageName();
                    mClassName = activityManager.getRunningTasks(1).get(0).topActivity.getClassName();
                }
Divyesh Boda
  • 258
  • 2
  • 12