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

Bug #1331869 reported by pjv
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Collectionista
Fix Committed
Medium
pjv

Bug Description

Bugsense:
https://www.bugsense.com/dashboard/project/98c9e403/errors/822538046
https://www.bugsense.com/dashboard/project/98c9e403/errors/931208083

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:629)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:231)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:326)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3695)
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:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)

Somewhere (trace doesn't say where), I am calling mContext.startActivity() on a mContext (Context) that is not an Activity or Fragment.

Related branches

Revision history for this message
pjv (pjv) wrote :

To fix, I have made the Context type more specific as Activity everywhere necessary. I also used FLAG_ACTIVITY_NEW_TASK in one place, Preferences, to avoid the possibility of this error. In CustomActionProvider I now have 2 context objects (one needs to be themed).

pjv (pjv)
Changed in collectionista:
status: New → Fix Committed
importance: Undecided → Low
assignee: nobody → pjv (pjv)
importance: Low → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.