gpt4 book ai didi

android - 自动链接不适用于 HTC - HtcLinkifyDispatcher

转载 作者:太空宇宙 更新时间:2023-11-03 11:51:14 25 4
gpt4 key购买 nike

我在我的 Android 应用程序的 TextView 上使用 android:autoLink 设置为 web 以启用可点击链接。但是,如果我在升级到 ICS 的 HTC Desire S 上运行它,当我点击其中一个链接时,我会收到以下异常

android.content.ActivityNotFoundException: Unable to find explicit activity class 
{com.htc.HtcLinkifyDispatcher/
com.htc.HtcLinkifyDispatcher.HtcLinkifyDispatcherActivity};
have you declared this activity in your AndroidManifest.xml?

at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1634)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
at android.app.Activity.startActivityFromChild(Activity.java:3519)
at android.app.Activity.startActivityForResult(Activity.java:3271)
at android.app.Activity.startActivity(Activity.java:3358)
at woodsie.avalanche.info.InfoActivity.startActivity(InfoActivity.java:61)
at android.text.style.LinkifyURLSpan.onClick(LinkifyURLSpan.java:73)

尝试注册 HtcLinkifyDispatcherActivity 让我无处可去,因为该类不在我的构建路径上。

最佳答案

我找到的与此相关的最佳文章是 The Linkify Problem: The Detection and the Mitigation .

但是,我没有尝试拦截和替换 URLSpan 类,而是降低了一个级别并覆盖了 TextView 的父 Activity 上的 startActivity()

@Override
public void startActivity(Intent intent) {
try {
/* First attempt at fixing an HTC broken by evil Apple patents. */
if (intent.getComponent() != null
&& ".HtcLinkifyDispatcherActivity".equals(intent.getComponent().getShortClassName()))
intent.setComponent(null);
super.startActivity(intent);
} catch (ActivityNotFoundException e) {
/*
* Probably an HTC broken by evil Apple patents. This is not perfect,
* but better than crashing the whole application.
*/
super.startActivity(Intent.createChooser(intent, null));
}
}

Hacky 但简单,而且似乎有效。

关于android - 自动链接不适用于 HTC - HtcLinkifyDispatcher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13691241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com