pkgList Alanı
Şöyle yaparız
Şöyle yaparız
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> appProcesses= activityManager.getRunningAppProcesses();
for (RunningAppProcessInfo appProcess : appProcesses) {
PackageInfo p = null;
try {
p = this.getPackageManager().getPackageInfo(appProcess.pkgList[0],
PackageManager.GET_PERMISSIONS);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if(p != null && p.packageName.equals(getPackageName()) &&
appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND){
Log.d("Is in background:", "false");
return false;
}
}
Log.d("Is in background:", "true");
Hiç yorum yok:
Yorum Gönder