使用Linkify Android进行公开活动 [英] Open Activity with Linkify Android
本文介绍了使用Linkify Android进行公开活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户单击带有linkify的textView时,我想打开活动". 这是我的代码:
i want to open Activity when users click on textView with linkify... Heres my code:
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);
和我的Android manifest.xml
and my Android 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 时,它会引发以下异常:
And when users click on textView, it throws following exception :
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://Solution.Project.welcomeactivity (has extras) }
推荐答案
您的意图过滤器应如下所示:
Your intent filter should look like below:
<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>
您缺少数据标记,如下所示
方案可以是http或您自己定制的方案.
scheme could be http or your own customized one.
主机是链接,例如xyz.com
host is the link eg xyz.com
pathPrefix 是可选的,例如/homepage
pathPrefix is optional like /homepage
<data android:scheme="content"
android:host="Solution.Project.WelcomeActivity" />
这篇关于使用Linkify Android进行公开活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文