Calling startActivity() from outside of an Activity

作者:vkvi 来源:ITPOW(原创) 日期:2018-7-20

在 Adapter 中 startActivity 时,出现错误:

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

原来:

传入给 Adapter 的 context 不对,应该是某个 Activity 的 context,误传为了 getApplicationContext()。

相关文章