开发者

Download apk from market to sdcard programmatically

I would like to download an .apk file on the market to the sd-card without any user interaction (I mean to do it in background, without launching a browser or the Market Applicatio开发者_JAVA技巧n)?

Is there a special URL to use?

Something like http://market.android.com/details?id=<your_package_name> always launch the Market Application, doesn't it?


You can't do that. You can, however, download an APK file from an outside source bu using the method suggested above. This will notify the user via toast something like "Starting Download" and will not install the apk automatically.


Have you tried HttpURLConnection?

    HttpURLConnection con = null;
    try
    {
        URL url = new URL(url_str);
        con = (HttpURLConnection)url.openConnection();
        InputStream input_stream = con.getInputStream();
        ...
    }
    catch (MalformedURLException e) { ErrorMSG("Bad URL"); }
    catch (IOException e) { ErrorMSG("Failed to download file from input stream"); }
    finally
    {
        if (con != null) con.disconnect();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜