欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android中怎么實現(xiàn)自動更新-創(chuàng)新互聯(lián)

今天就跟大家聊聊有關(guān)Android中怎么實現(xiàn)自動更新,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

成都創(chuàng)新互聯(lián)公司是一家專業(yè)的成都網(wǎng)站建設(shè)公司,我們專注成都網(wǎng)站設(shè)計、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷、企業(yè)網(wǎng)站建設(shè),賣鏈接,廣告投放為企業(yè)客戶提供一站式建站解決方案,能帶給客戶新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計到用戶體驗提高,創(chuàng)新互聯(lián)力求做到盡善盡美。
import java.io.File;  

import java.io.FileOutputStream;

import java.io.IOException;  

import java.io.InputStream;  

import org.apache.http.HttpEntity;  
import org.apache.http.HttpResponse;  
import org.apache.http.client.ClientProtocolException;  
import org.apache.http.client.HttpClient;  
import org.apache.http.client.methods.HttpGet;  
import org.apache.http.impl.client.DefaultHttpClient;  
  
import android.app.AlertDialog;  
import android.app.Dialog;  
import android.app.ProgressDialog;  
import android.content.DialogInterface;  
import android.content.Intent;  
import android.net.Uri;  
import android.os.Bundle;  
import android.os.Environment;  
import android.os.Handler;  
  
public class Update extends BaseActivity {  
    public ProgressDialog pBar;  
    private Handler handler = new Handler();  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.update);  
        Dialog dialog = new AlertDialog.Builder(Update.this).setTitle("系統(tǒng)更新")  
                .setMessage("發(fā)現(xiàn)新版本,請更新!")// 設(shè)置內(nèi)容  
                .setPositiveButton("確定",// 設(shè)置確定按鈕  
                        new DialogInterface.OnClickListener() {  
  
                            @Override  
                            public void onClick(DialogInterface dialog,  
                                    int which) {  
                                pBar = new ProgressDialog(Update.this);  
                                pBar.setTitle("正在下載");  
                                pBar.setMessage("請稍候...");  
                                pBar  
                                        .setProgressStyle(ProgressDialog.STYLE_SPINNER);  
                                downFile("http://url:8765/OA.apk");   
                                   
                            }  
  
                        }).setNegativeButton("取消",    
                        new DialogInterface.OnClickListener() {  
                            public void onClick(DialogInterface dialog,  
                                    int whichButton) {  
                                // 點擊"取消"按鈕之后退出程序  
                                  
                            }  
                        }).create();// 創(chuàng)建  
        // 顯示對話框  
        dialog.show();  
  
    }  
  
    void downFile(final String url) {  
        pBar.show();  
        new Thread() {  
            public void run() {  
                HttpClient client = new DefaultHttpClient();  
                // params[0]代表連接的url  
                HttpGet get = new HttpGet(url);  
                HttpResponse response;  
                try {  
                    response = client.execute(get);  
                    HttpEntity entity = response.getEntity();  
                    long length = entity.getContentLength();  
                    InputStream is = entity.getContent();  
                    FileOutputStream fileOutputStream = null;  
                    if (is != null) {  
  
                        File file = new File(Environment  
                                .getExternalStorageDirectory(), "OA.apk");  
                        fileOutputStream = new FileOutputStream(file);  
                          
                        byte[] buf = new byte[1024];  
                        int ch = -1;  
                        int count = 0;  
                        while ((ch = is.read(buf)) != -1) {  
                            // baos.write(buf, 0, ch);  
                            fileOutputStream.write(buf, 0, ch);  
                            count += ch;  
                            if (length > 0) {  
                              
                            }  
  
                        }  
  
                    }  
                    fileOutputStream.flush();  
                    if (fileOutputStream != null) {  
                        fileOutputStream.close();  
                    }  
                    down();  
                } catch (ClientProtocolException e) {  
                    // TODO Auto-generated catch block  
                    e.printStackTrace();  
                } catch (IOException e) {  
                    // TODO Auto-generated catch block  
                    e.printStackTrace();  
                }  
            }  
  
        }.start();  
  
    }  
  
    void down() {  
        handler.post(new Runnable() {  
            public void run() {  
                pBar.cancel();  
                update();  
            }  
        });  
  
    }  
  
    void update() {  
  
        Intent intent = new Intent(Intent.ACTION_VIEW);  
        intent.setDataAndType(Uri.fromFile(new File("/sdcard/OA.apk")),  
                "application/vnd.android.package-archive");  
        startActivity(intent);  
    }  
  
}

看完上述內(nèi)容,你們對Android中怎么實現(xiàn)自動更新有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

文章題目:Android中怎么實現(xiàn)自動更新-創(chuàng)新互聯(lián)
網(wǎng)頁URL:http://aaarwkj.com/article0/iopio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站品牌網(wǎng)站制作、網(wǎng)站設(shè)計網(wǎng)頁設(shè)計公司、做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
青青草成年人免费视频| 性欧美一区二区三区| 亚洲av乱码国产精品观看 | 日木av中文字幕女女同性| 国产超碰久久久久久精品| 国产成年人在线免费观看| 麻豆国产97在线精品一区| 蜜臀在线免费观看av| 国产精品免费网站在线观看| 国产成人综合久久二区| 黄片免费视频大全在线观看| 麻豆国产精品原创av男女| 国产在线观看国产精品| 91亚洲国产成人精品性色| 色91精品在线观看剧情| 久久精品国产亚洲av波多| 色婷婷av一二三区竹菊| 亚洲成人av网址大全| 亚洲三级黄片免费播放| 福利一区福利二区视频| 亚洲国产香蕉视频在线播放| 午夜丁香婷婷爽少妇av| 91精彩啦在线看国产| 亚洲午夜福利啪啪啪| 精品国产一区av在线| 人人妻人人澡人人爽老妇| 久久精品亚洲精品国产| 91青青草原免费观看| 午夜啪视频免费在线观看| 人妻少妇偷人精品免费看| 亚洲码欧美码一区二区三区| 囗交囗爆吞精在线视频| 国产日产亚洲综合一区| 欧美欧美欧美欧美在线| 日日做日夜夜操天天搞| 国产婷婷精品一区二区| 亚洲欧美另类熟女丝袜| 日本国内一区二区三区四区视频| 国产原创剧情免费观看av| 日韩在线啊啊啊的视频| 视频一区视频二区在线|