Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla

在调用Context.startActivity(intent)的时候报错,信息如下:

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

解决方法:

在前面加上intent.addFlags(FLAG_ACTIVITY_NEW_TASK)或者使用Activity.startActivity(intent)

 

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla_第1张图片

你可能感兴趣的:(Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK fla)