更新应用程序OTA [英] Updating an application OTA

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

问题描述

我开发一个应用程序,将可从网站(行情很可能也一样)。我在此刻的问题是如何处理的更新的应用程序。我知道如何检查版本逆水之一,我知道,如果我需要更新它。问题是...怎么了?

I'm developing an application that will be available from a website (market probably as well). The problem I'm having at the moment is how to handle the updates to the app. I know how to check the version against the current one and I know if I need to update it. Question is...how?

有没有一种方法,我可以从网站上下载的APK,并开始安装过程?用户必须确认,当然,但我只是希望能够开始给他。目前,我正在做这样的:

Is there a way I can download an APK from the website and start the install process? The user will have to confirm of course, but I just want to be able to start it for him. At the moment I'm doing this:

private void doUpgrade() {
    // TODO Auto-generated method stub
    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.upgrade));
    builder.setIcon(R.drawable.help);
    builder.setMessage(getString(R.string.needUpgrade));
    builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

            Map<String, String> data = new HashMap<String, String>();

            try {
                HttpResponse re = Registration.doPost("http://www.android-town.com/appRelease/AndroidTown.apk",data);

                int statusCode = re.getStatusLine().getStatusCode();
                closeApp();

            } catch (ClientProtocolException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), getString(R.string.noURLAccess), Toast.LENGTH_SHORT).show();
                closeApp();
            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), getString(R.string.noURLAccess), Toast.LENGTH_SHORT).show();
                closeApp();
            }
        }
    });
    builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            dialog.cancel();
            closeApp();
        }
    });
    builder.show();
}

但它并没有真正做任何事情......我应该打开的URL中的web视图?新运行的线程?任何其他办法吗?请帮助:)

But it doesn't really do anything...should I open a webView with the URL? A new runnable thread? Any other way? Please help :)

干杯

推荐答案

最简单的就是刚刚推出的意图来打开下载URL的浏览器。这将下载 APK ,然后用户可以通过点击它的下载管理器进行安装。

Easiest is just to launch an Intent to open the download URL in the Browser. This will download the APK and the user can then install it by clicking on it in the download manager.

您说的话,这将处理OTA分离到市场,因此用户应该已经禁用允许来自非市场来源的应用程序,当他们最初安装在您的应用程序。

You are saying that this will handle OTA separate to the market so the user should already have disabled "Allow apps from non-Market sources" when they initially installed your app.

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

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