Android
- 10 ответов
- 0 вопросов
2
Вклад в тег
Runnable appsChecker = new Runnable()
{
//@Override
public void run() {
boolean inForeground = false;
List<RunningAppProcessInfo> appProcesses= null;
appProcesses = activityManager.getRunningAppProcesses();
if (appProcesses!=null) {
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {//.IMPORTANCE_FOREGROUND) {
// Log.d("timer vis",appProcess.processName+":"+appProcess.importance);
if (appProcess.processName.equals("com.bigbuzzy.business")) {
inForeground = true;
}
}
}
}
//Log.d("timer",inForeground+":"+ inWiFi);
if (!inForeground) {
/*
boolean isSystem = false;
for (RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
PackageInfo p = null;
try {
p = ForegroundService.this.getPackageManager().getPackageInfo(
appProcess.pkgList[0], PackageManager.GET_PERMISSIONS);
}
catch (NameNotFoundException e)
{
}
if (p != null) {
String ss = "";
if (p.requestedPermissions==null) ss = null;
else {
for (String s : p.requestedPermissions) {
ss= ss + s;
}
}
boolean issSystem = (p.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1;
Log.d("System", appProcess.processName+":"+p.versionCode);
}
}
}
*/
Intent i =new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setClassName("com.dgdfgdfgd.business", "com.dfgdfgdfgdfgdgdgf.business.MainMenuActivity");
startActivity(i);
i = null;
}
appProcesses= null;
handler.postDelayed(appsChecker, INTERVAL);
//}
}
};