Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final String packageName = getApplicationContext().getPackageName();
- for (Object object : packagezList) {
- for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
- boolean b= appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
- if (!b) {
- Log.e("is in foreground", getApplicationContext().getPackageName());
- // Provide the packagename(s) of apps here, you want to show password activity
- if (((appProcess.processName.contains((CharSequence) object)) &&
- (!appProcess.processName.contains(getApplicationContext().getPackageName()
- )) && (!appProcess.processName.equals(packageName)))) {
- /* // you have to make this check even better
- Log.e("Boom Motherfucker3", getApplicationContext().getPackageName());
- Log.e("Just Blocked: ", appProcess.processName);
- Intent i = new Intent(getApplicationContext(), LockScreenActivity.class);
- i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
- i.putExtra("", "");
- startActivity(i);*/
- }
- }
- }
- }
- }
- } catch (Exception e) {
- // Log.e("Foreground App", e.getMessage(), e);
- }
Advertisement
Add Comment
Please, Sign In to add comment