我想在用户点击带有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);
和我的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 时,会抛出以下异常:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://Solution.Project.welcomeactivity (has extras) }
答案 0 :(得分:2)
您的意图过滤器应如下所示:
<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" />
答案 1 :(得分:0)
您必须在活动中使用provider
标记并匹配authority