androidabc


public static boolean isAppFront(Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> rapis = am.getRunningAppProcesses();
for (RunningAppProcessInfo rapi : rapis) {
if (rapi.processName.equals(context.getPackageName())) {
if (rapi.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
return true;
}
}
}
return false;
}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2021-09-26
  • 2021-10-18
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-07-15
相关资源
相似解决方案