2011-09-03 67 views
0

我想市场上下载.apk文件到sd卡无需任何用户交互(我的意思做,在后台,无需启动浏览器或市场应用)?下载APK到SD卡编程

有没有特别的URL可以使用?

喜欢的东西总是http://market.android.com/details?id=<your_package_name>推出市场应用,不是吗?

+0

我认为(不确定)market.android.com没有权利下载apk。它只是直接安装。 –

回答

0

你试过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(); 
    } 
1

你不能那样做。 但是,您可以使用上面建议的方法从外部源bu下载APK文件。 这将通过吐司通知用户像“开始下载”,并不会自动安装apk。