Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

安卓出现如下错误,需要增加FLAG_ACTIVITY_NEW_TASK标志

Intent intent1 = new Intent(getApplicationContext(), CameraActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(intent1);

  

原文地址:https://www.cnblogs.com/-Object/p/6664262.html