gpt4 book ai didi

Android App Intent Filter 有时不工作

转载 作者:太空宇宙 更新时间:2023-11-03 10:57:20 25 4
gpt4 key购买 nike

对于一个项目我遇到了一个很奇怪的问题:

深层链接在去年一直运行良好,但最近(自 2019 年 1 月开始)我们收到用户的投诉,称深层链接已停止工作(有人说 10 次中有 9 次)。

我们没有更改此代码的任何部分,并且很难重现此问题。

更奇怪的是,在我们自己遇到问题的稀疏时间里,Android 操作系统甚至不会通过“打开方式”对话框将我们的应用程序显示为一个选项。这向我们表明,操作系统有时会忘记应用程序在其 list 中注册了 intent-filters。

重新启动应用程序似乎可以解决此问题,并且深层链接会重新开始工作。每次我们从 Android Studio 进行新构建时,该应用程序似乎也能正常工作,这使得它很难重现。

我们的 list 有一个处理深层链接的特定 Activity :

<activity
android:name="com.company.DeepLinkActivity"
android:noHistory="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="ideal-payment"
android:scheme="com.company.ideal" />
<data
android:host="ideal-payment"
android:scheme="com-company-ideal" />

</intent-filter>

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="${appLinkIdealHost}"
android:pathPrefix="/ideal-betaling/landingpage"
android:scheme="https" />
</intent-filter>

<intent-filter android:autoVerify="true">
...
</intent-filter>

<intent-filter android:autoVerify="true">
...
</intent-filter>
</activity>

我们认为这可能与无法访问自动验证有关,但随后操作系统应显示“打开方式”对话框,当问题出现时不会出现这种情况。

有没有人遇到过类似的问题?任何帮助或建议将不胜感激。

最佳答案

当应用程序因异常而停止时,或者当用户从设置中强制停止它时,或者在某些设备中,当用户从历史记录(或从任务中)删除应用程序时,应用程序将被自动强制停止(这不是制造商的一个不错的选择)当应用程序处于停止状态时,其 list intentFilter 将不会被使用(当应用程序首次安装且从未打开时,它也处于此阶段)

While in stopped state, the application will not run for any reason, except by a manual launch of an activity, or an explicit intent that addresses an activity ,service or broadcast.

https://riptutorial.com/android/example/30592/android-stopped-state


您提到的大多数 Android 版本都是 8 或更高版本,因此下面的报价也可能有用,但这是针对服务和广播接收器的。

Whenever an app runs in the background, it consumes some of the device's limited resources, like RAM. This can result in an impaired user experience, especially if the user is using a resource-intensive app, such as playing a game or watching video. To improve the user experience, Android 8.0 (API level 26) imposes limitations on what apps can do while running in the background.

https://developer.android.com/about/versions/oreo/background

关于Android App Intent Filter 有时不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55005186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com