lockAppName 是需要判断Activity的全称(包括包名).

private boolean getTopApp(Context mContext) {
        String lockAppName = "com.celltick.lockscreen.LockerActivity";
        String topActivityName = "";
        ActivityManager am = (ActivityManager) mContext
                .getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> runningTasks = am
                .getRunningTasks(1);
        if (runningTasks != null && !runningTasks.isEmpty()) {
            ActivityManager.RunningTaskInfo taskInfo = runningTasks.get(0);
            topActivityName = taskInfo.topActivity.getClassName();
        }
        if (lockAppName.equals(topActivityName)) {
            return true;
        }
        return false;
    }

 

相关文章:

  • 2022-02-13
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案