Good day.
How to make an activity that can not be closed. The device is used as a measuring device, the user does not have to access other functions.
I check in the service whether the activity is running and if I don’t start it, but on some phones after pressing the home button you can manage to get into the dialer, some in the settings and at the same time the activity does not sound
while (!Setting.getPassword(getApplicationContext()).equals(CryptoUtil.getHash(Setting.SALT1 + Setting.pseudoID+Setting.SALT2) )){ AudioManager aManager = (AudioManager) getSystemService(AUDIO_SERVICE); aManager.setRingerMode(aManager.RINGER_MODE_SILENT); if (!isRunning(getApplication())) { Intent dialogIntent = new Intent(getBaseContext(), MyActivity.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplication().startActivity(dialogIntent); } } public boolean isRunning(Context ctx) { ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE); for (ActivityManager.RunningTaskInfo task : tasks) { if (ctx.getPackageName().equalsIgnoreCase(task.baseActivity.getPackageName())) return true; } return false; }