自我更新的应用程序 [英] Self updating app

查看:30
本文介绍了自我更新的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL:DR;版本;)

  • 我的应用应该在没有用户交互的情况下运行(自动启动等工作)

  • my app should run without user interaction (autostart etc works)

它应该在没有任何用户交互的情况下更新自身(通过 apk)

it should update itself (via apk) without any user interaction

root 设备是可能的

rooted devices are possible

.

问题:

  • 从服务器查询较新的 apk 有效
  • 当以(查看?)意图启动 apk 时,安装应用"提示会弹出并需要用户确认

如何在没有任何用户交互的情况下解决此问题?

How do I solve this without any user interaction?

http://code.google.com/p/auto-update-apk-client/这似乎是一个解决方案,但必须有更好的方法.

http://code.google.com/p/auto-update-apk-client/ This seems to be a solution, but there must be better approach.

我已经找到了:在 Android 上以编程方式安装应用程序

但这并不能解决我的问题.

but that doesn't solve my problem.

推荐答案

解决了!:D

它仅适用于root 设备,但效果很好.使用 unix cmd "pm" (packageManager) 允许您在以 root 身份执行时从 sdcard 安装 apk.

It just works in rooted devices but works perfectly. Using the unix cmd "pm" (packageManager) allows you to install apks from sdcard, when executing it as root.

希望这可以在未来帮助一些人.

Hope this could help some people in the future.

public static void installNewApk()
{
        try
        {
            Runtime.getRuntime().exec(new String[] {"su", "-c", "pm install -r /mnt/internal/Download/fp.apk"});
        }
        catch (IOException e)
        {
            System.out.println(e.toString());
            System.out.println("no root");
        }
}

所需权限:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

这篇关于自我更新的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆