[android-developers] Re: GestureOverlayView throwing exception when used with Linkify

2010-05-28 Thread MrChaz
The context I'm using to do what?  Creating the GestureOverlayView?

On May 28, 5:26 pm, Romain Guy romain...@android.com wrote:
 Here's your problem:

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

 The problem is not using a GestureOverlayView with a TextView, the
 problem comes from the Context you are using.





 On Fri, May 28, 2010 at 7:36 AM, MrChaz mrchazmob...@gmail.com wrote:
  Hi,

  Anyone else run into this and have a solution?
  Basically I have a GestureOverlayView over the top of a TextView.  The
  TextView has Linkify.addLinks(tv, Linkify.ALL) called on it.

  If you click on an URL in the TextView the following exception is
  thrown
  Running 2.2 (apparently a pre-release version)

  05-28 15:35:04.423: ERROR/AndroidRuntime(25209): FATAL EXCEPTION: main
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):
  android.util.AndroidRuntimeException: Calling startActivity() from
  outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK
  flag. Is this really what you want?
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.ContextImpl.startActivity(ContextImpl.java:617)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.text.style.URLSpan.onClick(URLSpan.java:62)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java 
  :
  216)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.widget.TextView.onTouchEvent(TextView.java:6577)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.View.dispatchTouchEvent(View.java:3766)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.gesture.GestureOverlayView.dispatchTouchEvent(GestureOverlayView.ja 
  va:
  505)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow
  $DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneW 
  indow.java:
  1107)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.Activity.dispatchTouchEvent(Activity.java:2086)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow
  $DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.os.Handler.dispatchMessage(Handler.java:99)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.os.Looper.loop(Looper.java:123)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.ActivityThread.main(ActivityThread.java:4627)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  java.lang.reflect.Method.invokeNative(Native Method)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  java.lang.reflect.Method.invoke(Method.java:521)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.os.ZygoteInit
  $MethodAndArgsCaller.run(ZygoteInit.java:868)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  dalvik.system.NativeStart.main(Native Method)

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 

[android-developers] Re: GestureOverlayView throwing exception when used with Linkify

2010-05-28 Thread MrChaz
Right, fixed.

passing getApplicationContext() rather than 'this' was the problem.

Thanks.

On May 28, 5:26 pm, Romain Guy romain...@android.com wrote:
 Here's your problem:

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

 The problem is not using a GestureOverlayView with a TextView, the
 problem comes from the Context you are using.





 On Fri, May 28, 2010 at 7:36 AM, MrChaz mrchazmob...@gmail.com wrote:
  Hi,

  Anyone else run into this and have a solution?
  Basically I have a GestureOverlayView over the top of a TextView.  The
  TextView has Linkify.addLinks(tv, Linkify.ALL) called on it.

  If you click on an URL in the TextView the following exception is
  thrown
  Running 2.2 (apparently a pre-release version)

  05-28 15:35:04.423: ERROR/AndroidRuntime(25209): FATAL EXCEPTION: main
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):
  android.util.AndroidRuntimeException: Calling startActivity() from
  outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK
  flag. Is this really what you want?
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.ContextImpl.startActivity(ContextImpl.java:617)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.text.style.URLSpan.onClick(URLSpan.java:62)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java 
  :
  216)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.widget.TextView.onTouchEvent(TextView.java:6577)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.View.dispatchTouchEvent(View.java:3766)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.gesture.GestureOverlayView.dispatchTouchEvent(GestureOverlayView.ja 
  va:
  505)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow
  $DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneW 
  indow.java:
  1107)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.Activity.dispatchTouchEvent(Activity.java:2086)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.policy.impl.PhoneWindow
  $DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.os.Handler.dispatchMessage(Handler.java:99)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.os.Looper.loop(Looper.java:123)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  android.app.ActivityThread.main(ActivityThread.java:4627)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  java.lang.reflect.Method.invokeNative(Native Method)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  java.lang.reflect.Method.invoke(Method.java:521)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.os.ZygoteInit
  $MethodAndArgsCaller.run(ZygoteInit.java:868)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  05-28 15:35:04.423: ERROR/AndroidRuntime(25209):     at
  dalvik.system.NativeStart.main(Native Method)

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions