多个 Android 深 link,app 进入 onResume()

Multiple Android deep link, app goes in onResume()

我有一个包含两个 link 的 html 页面,如下所示:

<a href="myApp:sometext1;scheme=myApp">Test 1</a>

<a href="myApp:sometext2;scheme=myApp">Test 2</a>

我用 android 互联网应用程序打开它。在我的 "Hello word" 清单应用程序中,我声明:

<activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter android:label="testapp">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="myApp" />
        </intent-filter>
    </activity>

我可以用两个 links.The 打开我的应用程序,第一次我点击两个 link 我的应用程序启动并通过 onCreate(我的应用程序在点击之前不在后台)。第二次(app现在在最近的任务中),第一个link按时间顺序点击之前只通过onResume,第二次通过onCreate。如果我尝试打开 links n 次直到我从最近终止应用程序,这将是行为。有什么想法吗?谢谢!

一个Androidactivity,默认可以实例化多次。您应该使用 android:launchMode="singleTask" 来覆盖此行为。如果您 - here is the link to documentation.

,还有其他一些标志可能会让您感兴趣