我想打开活动时,用户点击textView与链接.这是我的代码:
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) }发布于 2016-09-16 12:09:43
您的意图筛选器应该如下所示:
<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,也可以是您自己的自定义方案。
主机是链接,如xyz.com
pathPrefix与/homepage一样是可选的。
<data android:scheme="content"
android:host="Solution.Project.WelcomeActivity" />发布于 2014-09-02 18:18:26
您必须在您的活动中使用provider标记与authority匹配。
https://stackoverflow.com/questions/25629691
复制相似问题