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

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

问题描述

TL:DR;版本;)

TL:DR; version ;)

- 我的应用程序应该运行,而无需用户交互(自动启动等作品)

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

- 它会自动更新(通过APK)无需任何用户交互

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

-rooted设备是可能的。

-rooted devices are possible

问题: 从服务器的工作原理-querying一个新的APK - 当开始用的APK(查看?)的意图,安装程序的提示持久性有机污染物和需要用户确认

problem: -querying a newer apk from a server works -when starting the apk with a (view?) intent, the "install app" prompt pops and needs a user confirmation

我要如何解决这个问题没有任何用户交互?

How do I solve this without any user interaction?

<一个href="http://$c$c.google.com/p/auto-update-apk-client/">http://$c$c.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.

我已经发现了这一点:<一href="http://stackoverflow.com/questions/4604239/install-application-programmatically-on-android">Install以编程方式在Android 应用

I already found this: Install Application programmatically on Android

但这并没有解决我的概率。

but that doesn't solve my prob.

THX很多提前。

推荐答案

解决了这个问题! :D

Solved it! :D

这只是工作的根设备,而且完美。 使用Unix CMDPM(packageManager)允许您执行时,它以root身份从安装SD卡,的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");
        }
}

所需的权限:

Required permissions:

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

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

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