【发布时间】:2017-08-22 13:46:31
【问题描述】:
我正在尝试获取某种文本模式来打开 Intent。文本模式正确链接。单击列表视图中的文本@username 应打开下面指定的活动。相反,它会打开一个对话框,上面写着"Open with... No apps can perform this action.",并且活动不会改变。这里有什么?
链接代码:
// Linkify @mentions
Linkify.TransformFilter filter = (match, url) -> match.group();
Pattern mentionPattern = Pattern.compile("@([A-Za-z0-9_-]+)");
String mentionScheme = "com.test.android.activity.UserProfileActivity://";
Linkify.addLinks(feedItemView.messageText, mentionPattern, mentionScheme, null, filter);
清单:
<activity
android:name=".activity.UserProfileActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:parentActivityName=".activity.UserProfileActivity"
android:screenOrientation="portrait"
tools:ignore="UnusedAttribute">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="com.test.android.activity.UserProfileActivity" />
</intent-filter>
</activity>
我以此为指导:http://cogitas.net/blog/2011/01/05/linkify-your-android-textview/
【问题讨论】: