2016-12-15 144 views
20

步骤: 1)开启Android应用程序(具有cordova建)Android应用开始更新停止

2)然后我打电话cordova-webintent安装更新 https://github.com/Initsogar/cordova-webintent

3)我按下安装并开始安装,但几秒钟后,应用程序强制停止并关闭,而不是安装并打开更新的应用程序。

这个问题出现前一段时间,我不明白为什么发生这种情况,因为cordova-webintentcordova相同的版本。

4)应用程序强制停止后,点击应用程序图标,但出现消息“应用程序未安装”。应用程序在几秒钟后继续在后台安装。我再次点击应用程序图标,打开更新的应用程序。

请帮助解决这个问题与安装时,应用程序强制停止。

日志:

E:\工作\ hello1>亚行logcat ActivityManager:我com.example.hello1:d *:S

---------开始系统的

I/ActivityManager(715):【背景服务优先级调整]设置callerFg作为假对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

---------主开始

I/ActivityManager(715):START u0 {dat = file:///storage/emulated/0/filename1.apk cmp = com.android。 packageinstaller/.InstallAppProgress(具有额外)}从上显示0 UID 10072 I/ActivityManager(715):[AppLaunch]显示显示com.android.packageinstaller/.InstallAppProgress:+ 135ms

I/ActivityManager(715):强制停止com.example.hello1 appid = 10657 user = -1:卸载pkg

I/ActivityManager(715):杀死19149:com.example.hello1/u0a657(形容词1):停止com.example.hello1

W/ActivityManager(715):通知应用开关退出的packageName = com的.example.hello1 I/ActivityManager(715):强制结束活动ActivityRecord {16a2ad7e U0 com.example.hello1/.MainActivity t2758}

I/ActivityManager(715):强制结束活动ActivityRecord {32eb6933 U0 com.android .packageinstaller/.InstallAppProgress t2758}

W/ActivityManager(71 5):虚假的ProcessRecord死亡{2590ad4d 19149:com.example.hello1/u0a657},curProc for 19149:null

I/ActivityManager(715):Force stopping com。example.hello1的appid = 10657用户= -1:更新PKG I/ActivityManager(715):强制关闭com.example.hello1的appid = 10657用户= 0:PKG删除

+0

你能提供一些像Android版本,科尔多瓦版本的更多信息,它是否是设备特定的?还有,你的应用程序在更新过程中是否会出现背景?请抛出一些光线,以深入挖掘 – Gandhi

+0

- Android 5.0.1 - 科尔多瓦6.3.1 - 我检查了联想和三星平板电脑。 - 是的,应用程序关闭,并在更新后进入背景 – IuliiaBoiko

+0

由于应用程序进入后台,我怀疑intent事件可能不会像web意图插件问题中提到的那样触发 - https://github.com/Initsogar/cordova-webintent/issues/27 https://github.com/Initsogar/cordova-webintent/pull/28请检查链接,并让我知道它是否有帮助 – Gandhi

回答

0

当你开始安装意图/操作,Android操作系统强制关闭正在运行的应用程序,然后清理旧的应用程序文件(基本上它将删除它们 - 应用程序内部数据文件夹/沙箱除外),然后它复制新的应用程序文件此后您可以启动应用程序

应用程序的关闭在安装过程中是必要的,因为应用程序正在运行时,它可能会保存文件锁定,从而导致无法删除旧文件

“强制停止”对话框是android不成功进程“退出信号”的标准行为。您可以通过使用Thread.UncaughtExceptionHandler

public void uncaughtException(Thread t, Throwable e){ 
    e.printStackTrace() 
    System.exit(0);// exit the app normally, with 0 (OK) signal - will bypass the "force close" UI 
} 

我不建议使用上述伎俩来解决你的问题,覆盖了整个“强行停止”机制 - 它的唯一目的是展示它让你了解它是如何工作的,并最终帮助你

进一步排查为了实现无缝自动升级的应用程序,你必须:

  1. 下载新的APK(必须由相同的证书和您现有的应用程序上签字电话)
  2. 设置延迟安装意图/操作using PendingIntent延迟您的应用程序需要关闭的时间+一些缓冲时间取决于设备性能(例如,500ms-1sec是合理的)
  3. 退出当前运行应用程序System.exit(0)