我想在用户使用 linkify 单击 textView 时打开 Activity...
这是我的代码:
Pattern tagMatcher = Pattern.Compile("#([A-Za-z0-9_-]+)");
//Scheme for Linkify, when a word matched tagMatcher pattern,
//that word is appended to this URL and used as content URI
String newActivityURL = "content://Solution.Project.WelcomeActivity";
//Attach Linkify to TextView
wrapper.Text.Text = post.PostText;
Linkify.AddLinks(wrapper.Text, tagMatcher, newActivityURL);
和我的安卓manifest.xml
<application android:icon="@drawable/Icon" android:label="Welcome">
<activity android:name=".WelcomeActivity" android:label="@string/WelcomeText">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
当用户点击textView,它抛出以下异常:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://Solution.Project.welcomeactivity (has extras) }
您的意图过滤器应如下所示:
<intent-filter android:label="@string/filter_title_viewgizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="content"
android:host="Solution.Project.WelcomeActivity" />
</intent-filter>
你失踪了data标签如下图
scheme可以是 http 或您自己定制的。
host是链接,例如 xyz.com
路径前缀是可选的,例如 /homepage
<data android:scheme="content"
android:host="Solution.Project.WelcomeActivity" />
Read 深度链接的 android 文档 https://developer.android.com/training/app-indexing/deep-linking.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)