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

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è)
国产一区二区乱码在线| 乱色熟女一区二区三区| 我的极品小姨在线观看| 全部网站免费在线观看等| 尤物在线观看精品视频| 91麻豆精品国产久久久| 国产剧情av一区在线观看| 日韩欧美亚洲精品中文字幕αv| 中文字幕一区二区三区三级| 国产欧美日韩一二三四| 18岁未成年禁止观看视频| 日本91一区二区不卡| 国产一级一片内射视频| 久草视频亚洲免费在线| 国产原创中文剧情性感av| 久久精品久久精品欧美大片| 深夜视频国产在线观看| 伊人久久大香线蕉av色婷婷色| 国产伦奸在线播放免费| 国产精品久久久久久爽| 日韩欧美一区二区三区不卡在线 | 欧美一级特黄免费大片| 日本韩国三级理伦久久久| 日本一区二区精品视频| 国产伦理自拍视频在线观看| 亚洲av色网在线观看| 一区二区不卡中文av| 人妻黄色这里只有精品| 熟女少妇精品一区二区三区| 日本一区二区三区精彩视频| 国产天堂亚洲国产碰碰| 亚洲国产精品成人久久蜜臀| 97久久久人妻精品一区| 日本韩国视频一区二区| 欧美老熟妇一区二区三区| 欧美黄色一区在线观看| 欧美伊人久久大综合精品| 很黄很刺激的视频中文字幕 | 线上免费看黄色亚洲片| 国产免费成人黄视频网站| av免费观看日韩永久|