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:628) at android.content.ContextWrapper.startActivity(ContextWrapper.java:258) at com.tencent.connect.auth.AuthDialog$LoginWebViewClient.shouldOverrideUrlLoading(ProGuard:235) at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:216) at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3690) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method)
Context中有一個startActivity方法,Activity繼承自Context,重載了startActivity方法。若是使用Activity的startActivity方法,不會有任何限制,而若是使用Context的startActivity方法的話,就須要開啓一個新的task,遇到上面那個異常的,都是由於使用了Context的startActivity方法。解決辦法是,加一個flag。java
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); android