0

For a banking application installed on POS android devices. the target is to detect when the user opens the settings and popup a lock screen. The twist is that the application has a custom launcher as usual in POS devices. with the code below, i can only detect the custom launcher.

            ActivityManager activityManager = (ActivityManager)
                    getSystemService(Context.ACTIVITY_SERVICE);

            List<ActivityManager.RunningTaskInfo> tasks = activityManager
                    .getRunningTasks(Integer.MAX_VALUE);

            for (ActivityManager.RunningTaskInfo task : tasks) {
                if (task.baseActivity.getPackageName().equalsIgnoreCase("com.android.settings")) {
                    Toast.makeText(this, " MyService Started", Toast.LENGTH_LONG).show();
                }
            }

i can only detect the MainActivity of the custom launcher!.

I've also tried different code implementation from the following links

two solutions were tested from here with no success

This library as well returns null always!

For permissions added to the Manifest

<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.REAL_GET_TASKS " />
<uses-permission
    android:name="android.permission.PACKAGE_USAGE_STATS"
    tools:ignore="ProtectedPermissions" />
coding
  • 1

0 Answers0