Disabling is clearly not possible. However, you can use a workaround for this. Create a service in your application that runs continuously in the background:
public class MasterService extends Service{
private ThreadPoolExecutor executor;
private Runnable runnable = new Runnable(){
@Override
public void run(){}
};
public MasterService(){
executor = new ThreadPoolExecutor(1, 1, 1, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
executor.execute(runnable);
return super.onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind(Intent intent) {
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onDestroy() {
super.onDestroy();
executor.shutdown();
}
};
startService(new Intent(this, MasterService.class)); .
Android ( ), , .
Runnable , . , , :
@Override
public void run(){
while(true) {
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
for (int i = 0; i < procInfos.size(); i++) {
if (procInfos.get(i).processName.equals("com.android.packageinstaller") && procInfos.get(i).importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
startActivity(new Intent(MasterService.this, OverlayActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY));
}
}
}
}
"", :
public class OverlayActivity extends Activity{
private ImageView view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view = new ImageView(this);
setContentView(view);
}
@Override
public void onBackPressed() {
}
};
"" , , "", , OverlayActivity .
, ββ . :
onDestroy , .- ,
com.android.settings.
, , , , .