www.cftea.com

Calling startActivity() from outside of an Activity

千一网络(原创)2018/7/20 14:24:16

在 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()。

<<返回首页<<