godanz
godanz
采纳率0%
2016-03-08 09:24 阅读 2.4k

Android 自定义dialog添加文字超链接,点击报错无法实现跳转

自定义dialog,添加文字超链接,点击超链接报错,同样方法,在activity中就能实现,什么原因??

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

6条回答 默认 最新

  • huaheshangxo 苍蝇小黑 2016-03-08 11:26

    Intent中加入这个试试:

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    
    
    点赞 1 评论 复制链接分享
  • Royal_lr Royal_lr 2016-03-08 09:29

    报错是报的什么错,,

    点赞 评论 复制链接分享
  • godanz godanz 2016-03-08 09:52

    抓取log如下
    01-01 02:49:07.928: E/InputEventReceiver(3774): Exception dispatching input event.
    01-01 02:49:07.929: E/MessageQueue-JNI(3774): Exception in MessageQueue callback: handleReceiveCallback
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.app.ContextImpl.startActivity(ContextImpl.java:1351)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.app.ContextImpl.startActivity(ContextImpl.java:1338)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.text.style.URLSpan.onClick(URLSpan.java:69)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:217)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.widget.TextView.onTouchEvent(TextView.java:8304)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.View.dispatchTouchEvent(View.java:8593)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2477)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1793)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.app.Dialog.dispatchTouchEvent(Dialog.java:778)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2438)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.View.dispatchPointerEvent(View.java:8799)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4638)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4496)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4063)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4029)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4166)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4037)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4223)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4063)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4029)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4037)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6457)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6413)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6366)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6631)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.os.MessageQueue.nativePollOnce(Native Method)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.os.MessageQueue.next(MessageQueue.java:148)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.os.Looper.loop(Looper.java:151)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at android.app.ActivityThread.main(ActivityThread.java:5624)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at java.lang.reflect.Method.invoke(Native Method)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at java.lang.reflect.Method.invoke(Method.java:372)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    01-01 02:49:07.932: E/MessageQueue-JNI(3774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
    01-01 02:49:07.933: D/AndroidRuntime(3774): Shutting down VM
    01-01 02:49:07.934: E/AndroidRuntime(3774): FATAL EXCEPTION: main
    01-01 02:49:07.934: E/AndroidRuntime(3774): Process: com.demo.tan, PID: 3774
    01-01 02:49:07.934: E/AndroidRuntime(3774): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.app.ContextImpl.startActivity(ContextImpl.java:1351)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.app.ContextImpl.startActivity(ContextImpl.java:1338)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.text.style.URLSpan.onClick(URLSpan.java:69)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:217)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.widget.TextView.onTouchEvent(TextView.java:8304)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.View.dispatchTouchEvent(View.java:8593)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2519)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2171)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2477)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1793)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.app.Dialog.dispatchTouchEvent(Dialog.java:778)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2438)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.View.dispatchPointerEvent(View.java:8799)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4638)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4496)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4063)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4029)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4166)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4037)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4223)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4063)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4029)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4037)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4010)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6457)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6413)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6366)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6631)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.os.MessageQueue.nativePollOnce(Native Method)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.os.MessageQueue.next(MessageQueue.java:148)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.os.Looper.loop(Looper.java:151)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at android.app.ActivityThread.main(ActivityThread.java:5624)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at java.lang.reflect.Method.invoke(Native Method)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at java.lang.reflect.Method.invoke(Method.java:372)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    01-01 02:49:07.934: E/AndroidRuntime(3774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

    点赞 评论 复制链接分享
  • LIN0801010231 AnotherM 2016-03-08 09:54

    代码又不贴,报什么错又不说,像我们这样没遇到过但愿意分析的也没办法咯

    点赞 评论 复制链接分享
  • VNanyesheshou zpy_公众号_码农修仙儿 2016-03-08 10:02

    代码调用对地方贴一下。

    点赞 评论 复制链接分享
  • dongfeng9ge 东风玖哥 2016-03-09 02:39

    楼主,贴logcat应该只贴红字

    点赞 评论 复制链接分享

相关推荐