2 godanz godanz 于 2016.03.08 17:24 提问

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

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

6个回答

huaheshangxo
huaheshangxo   2016.03.08 19:26

Intent中加入这个试试:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

crazy1235
crazy1235 加上这个报什么错?
接近 2 年之前 回复
godanz
godanz 非activity中调用startactivity的错误,但是加上了这个还是报同样的错
接近 2 年之前 回复
godanz
godanz 非activity中调用startactivity的错误,但是加上了这个还是报同样的错
接近 2 年之前 回复
Royal_lr
Royal_lr   Ds   Rxr 2016.03.08 17:29

报错是报的什么错,,

godanz
godanz   2016.03.08 17: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
LIN0801010231   2016.03.08 17:54

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

VNanyesheshou
VNanyesheshou   2016.03.08 18:02

代码调用对地方贴一下。

dongfeng9ge
dongfeng9ge   Ds   Rxr 2016.03.09 10:39

楼主,贴logcat应该只贴红字

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!