问题描述
我有一个的TextView
一些linkification(微博风格):
I have a TextView
with some linkification(twitter style):
Pattern pattern1 = Pattern.compile("@\\w+");
Linkify.addLinks(textView, pattern1, "my_activity://one=");
Pattern pattern2 = Pattern.compile("#\\w+");
Linkify.addLinks(textView, pattern2, "my_activity://two=");
在活动清单中声明与以下意图过滤器:
Activity declared in manifest with following intent filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="my_activity" />
</intent-filter>
意图被夹在活动的 onNewIntent
的方法,但该活动被重新启动之前(我想这是默认行为)。
Intent gets caught in the onNewIntent
method of the activity but the activity gets restarted before that(I assume this is default behaviour).
有没有办法接受这样的意图,无需重新启动活动?
Is there a way to receive such intent without restarting activity?
推荐答案
看起来 launchMode
的问题。你不应该使用 singleInstance
,因为这是只对主屏的更新换代产品。你应该尝试 singleTop
。这应该是足够为你正在尝试做的。
Looks like launchMode
is the problem. You shouldn't use singleInstance
, as that is only for HOME-screen replacements. You should try singleTop
. That should be enough for what you are trying to do.
这篇关于收到没有活动启动定制意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!