非Activity执行startActivity()

2018-03-20  本文已影响17人  qpan

在 非activity环境下(比如ApplicationContext,service等)下执行startActivity(),
会报以下异常:

               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) 
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) 
                                                                at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) 
                                                             Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:757)
                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:737)
                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
                                                                at com.pq.tools.MainActivity.transform(MainActivity.java:34)
上一篇 下一篇

猜你喜欢

热点阅读