關於Android檔案Apk下載的那點事

來源:互聯網
上載者:User

標籤:android   style   blog   http   io   os   ar   使用   java   

1、Android檔案Apk下載變ZIP壓縮包解決方案

 

如果你的下載伺服器為Nginx伺服器,那麼,在Nginx安裝目錄下的conf/mime.types檔案的對應位置,加上以下一行語句,指定APK檔案的MIME類型為 application/vnd.android.package-archive 即可:

[html] view plaincopy
  1. application/vnd.android.package-archive     apk;  


如果是java-web伺服器 只需要修改web.xml,加入下面這段文字

[html] view plaincopy
  1. <span style="font-size:18px;">  <mime-mapping>  
  2.         <extension>apk</extension>  
  3.         <mime-type>application/vnd.android.package-archive</mime-type>  
  4.     </mime-mapping></span>  

 

 

2、關於分享連結不能下載的問題

 

   如果你現在的是:http://www.baidu.com/1.apk

   需要在工程目錄下 建立名為 down.myapp.com 的檔案夾、並將1.apk放入

  : http://www.baidu.com/down.myapp.com/1.apk

   這樣就可以使用 直接分享,改連結在點擊後為跳轉到瀏覽器下載

 

3、根據請求來獲得請求的系統類別型

 

以java-web伺服器為例,可以通過http請求的request 來區分ios和android 系統進行分類下載

[java] view plaincopy
  1. <span style="font-size:18px;">String useragent = request.getHeader("user-agent");  
  2. if (useragent == null)  
  3.     useragent = "";  
  4.     if (useragent.toUpperCase().contains("Android".toUpperCase())) {  
  5.                 response.sendRedirect("/1.apk");  
  6.             }   
  7. else if (useragent.toUpperCase().contains("iPhone".toUpperCase())  
  8.     || useragent.toUpperCase().contains("ios".toUpperCase())  
  9.     || useragent.toUpperCase().contains("ipad".toUpperCase())) {  
  10.     response.sendRedirect(https://itunes.apple.com/***);  
  11.     } else {  
  12.         response.sendRedirect("/1.apk");  
  13.         }  
  14. </span>  



4、 其它

 

關於連結地址:通過伺服器產生短連結、方便使用者輸入。

                        例如:www.baidu.com/test1.apk 根據要求標頭最佳化 可以寫成www.baidu.com/test1
關於分享:在本地用戶端加入分享功能,使用新浪微博、等分享用戶端的二維碼、或者下載連結

關於市場提交:360手機小幫手,安智市場等都不錯、打包可以使用友盟等第三方打包工具

關於Android檔案Apk下載的那點事

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.