Android 应用程序开始使用 cordova-webintent 更新并强制停止
Posted
技术标签:
【中文标题】Android 应用程序开始使用 cordova-webintent 更新并强制停止【英文标题】:Android app starts updating with cordova-webintent and force stops 【发布时间】:2017-05-01 07:17:19 【问题描述】:步骤:
我打开了 android 应用程序(使用 cordova
构建)
然后我打电话给cordova-webintent
安装更新
我按了安装,它开始安装,但几秒钟后,应用强制停止并关闭,而不是安装和打开更新的应用。
这个问题是前段时间出现的,不明白为什么会这样,因为cordova-webintent
和cordova
的版本是一样的。
-
应用强制停止后,我点击应用图标,但出现“应用未安装”的消息。该应用程序会在几秒钟后继续在后台安装。我再次点击应用程序图标并打开更新的应用程序。
为什么安装时应用强制停止?
日志:
E:\work\hello1>adb logcat ActivityManager:I com.example.hello1:D *:S
--------- beginning of system
I/ActivityManager( 715): [Background Service Priority Adjustment] Set callerFg as false for service.getFlags():260
I/ActivityManager( 715): START u0 act=android.intent.action.VIEW dat=file:///storage/emulated/0/filename1.apk typ=application/vnd.android.package-archive cmp=com.android.packageinstaller/.PackageInstallerActivity from uid 10657 on display 0
--------- beginning of main
I/ActivityManager( 715): START u0 dat=file:///storage/emulated/0/filename1.apk cmp=com.android.packageinstaller/.InstallAppProgress (has extras) from uid 10072 on display 0
I/ActivityManager( 715): [AppLaunch] Displayed Displayed com.android.packageinstaller/.InstallAppProgress: +135ms
I/ActivityManager( 715): Force stopping com.example.hello1 appid=10657 user=-1: uninstall pkg
I/ActivityManager( 715): Killing 19149:com.example.hello1/u0a657 (adj 1): stop com.example.hello1
W/ActivityManager( 715): notify app switch quit packageName=com.example.hello1
I/ActivityManager( 715): Force finishing activity ActivityRecord16a2ad7e u0 com.example.hello1/.MainActivity t2758
I/ActivityManager( 715): Force finishing activity ActivityRecord32eb6933 u0 com.android.packageinstaller/.InstallAppProgress t2758
**W/ActivityManager( 715): Spurious death for ProcessRecord2590ad4d 19149:com.example.hello1/u0a657, curProc for 19149: null**
I/ActivityManager( 715): Force stopping com.example.hello1 appid=10657 user=-1: update pkg
I/ActivityManager( 715): Force stopping com.example.hello1 appid=10657 user=0: pkg removed
【问题讨论】:
您能否提供更多关于此的信息,例如 Android 版本、cordova 版本以及特定于设备的信息?另外,您的应用程序是否有机会在更新期间进入后台?请对此有所了解以深入了解 - Android 5.0.1 - Cordova 6.3.1 - 我检查了联想和三星平板电脑。 - 是的,应用程序在更新时关闭并进入后台 由于应用程序进入后台,我怀疑意图事件可能没有像网络意图插件问题中提到的那样触发 - github.com/Initsogar/cordova-webintent/issues/27 github.com/Initsogar/cordova-webintent/pull/28 请检查链接并让我知道是否它有帮助 @user3441891 如果您可以发布错误日志,那将非常有帮助。但是根据现有信息,我想您需要在单独的线程上调用此更新操作(类似于异步任务),也许它正在主线程上工作并导致此问题。 @raina77ow 是的,我发现了这个错误“W/ActivityManager(602): ProcessRecord2ed1f0f5 27636:com.example.test/u0a183 的虚假死亡,27636 的 curProc: null” 【参考方案1】:我有两个可能的原因来处理您的问题:
线程相关问题,取决于手机或平板电脑的类型 处理器(有多少线程可以同时运行)记住 cordoba-webintent 是一个基于异步的调用。 可能缺少两个相同的版本(cordoba-webintent 和 cordoba) 常用插件。 (插件本应存在但未包含在内!)在第一种情况下,首先检查您的清单:
<intent-filter>
<action android:name="com.example.yourapplication.hello1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
当然,它应该有一个唯一的名称。 然后在你调用 webintent 的地方检查你的 java 代码
startActivity(action: 'com.example.yourapplication.hello1')
try
可以方便地测试 webintent 是在应用程序的 MainActivity()
之前还是之后触发。如果您的 MainActivity() (has extras)
参数,还要检查意图“触发”顺序。
第二种情况是:
从gitHub下载cordoba-webintent 构建您的 apk 解压并找到插件目录 在你的项目中包含这个插件目录 这种方式将确保 webintent 安装了最新的 更新并且在您运行的自动更新期间没有任何问题 以前。我希望为您的案件指明不同的方法!
【讨论】:
以上是关于Android 应用程序开始使用 cordova-webintent 更新并强制停止的主要内容,如果未能解决你的问题,请参考以下文章
使用 nodejs 8、angularjs、ionic3、cordova8 更新 cordova-android 6 到 9、cordova-ios 5 到 6
用于 Cordova Android/iPhone 应用程序开发的 UI [关闭]
2020 年使用 cordova 的本地数据库 [Android/IOS]
Cordova: 仅使用HTML/JS即可制作一个Android或者iOS的App