当前位置: 首页 > news >正文

成都网站建设吧网站优化排名怎么做

成都网站建设吧,网站优化排名怎么做,网站建设不挣钱,网站正在维护中分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!截图如下:代码实现如下&#xff…

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

截图如下:

 

 

代码实现如下:

复制代码
package com.update.apk;import java.io.BufferedReader;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.URL;import org.apache.http.HttpEntity;import org.apache.http.HttpResponse;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.DefaultHttpClient;import org.json.JSONArray;import org.json.JSONObject;import android.app.Activity;import android.app.AlertDialog;import android.app.Dialog;import android.app.ProgressDialog;import android.content.Context;import android.content.DialogInterface;import android.content.Intent;import android.content.pm.PackageManager.NameNotFoundException;import android.net.Uri;import android.os.Bundle;import android.os.Environment;import android.os.Handler;import android.os.Message;import android.util.Log;public class MainActivity extends Activity {    /** Called when the activity is first created. */    String newVerName = "";//新版本名称    int newVerCode = -1;//新版本号    ProgressDialog pd = null;    String UPDATE_SERVERAPK = "ApkUpdateAndroid.apk";    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        if(getServerVer()){            int verCode = this.getVerCode(this);            if(newVerCode>verCode){                doNewVersionUpdate();//更新版本            }else{                notNewVersionUpdate();//提示已是最新版本            }        }    }        /**     * 获得版本号     */    public int getVerCode(Context context){        int verCode = -1;        try {            verCode = context.getPackageManager().getPackageInfo("com.update.apk", 0).versionCode;        } catch (NameNotFoundException e) {            // TODO Auto-generated catch block            Log.e("版本号获取异常", e.getMessage());        }        return verCode;    }        /**     * 获得版本名称     */    public String getVerName(Context context){        String verName = "";        try {            verName = context.getPackageManager().getPackageInfo("com.update.apk", 0).versionName;        } catch (NameNotFoundException e) {            Log.e("版本名称获取异常", e.getMessage());        }        return verName;    }        /**     * 从服务器端获得版本号与版本名称     * @return     */    public boolean getServerVer(){        try {            URL url = new URL("http://10.0.2.2:8080/ApkUpdateService/ver");            HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();            httpConnection.setDoInput(true);            httpConnection.setDoOutput(true);            httpConnection.setRequestMethod("GET");            httpConnection.connect();            InputStreamReader reader = new InputStreamReader(httpConnection.getInputStream());            BufferedReader bReader = new BufferedReader(reader);            String json = bReader.readLine();            JSONArray array = new JSONArray(json);            JSONObject jsonObj = array.getJSONObject(0);            newVerCode = Integer.parseInt(jsonObj.getString("verCode"));                    newVerName = jsonObj.getString("verName");        } catch (Exception e) {            // TODO Auto-generated catch block            e.printStackTrace();            return false;        }         return true;    }        /**     * 不更新版本     */    public void notNewVersionUpdate(){        int verCode = this.getVerCode(this);        String verName = this.getVerName(this);        StringBuffer sb = new StringBuffer();        sb.append("当前版本:");        sb.append(verName);        sb.append(" Code:");        sb.append(verCode);        sb.append("\n已是最新版本,无需更新");        Dialog dialog = new AlertDialog.Builder(this)        .setTitle("软件更新")        .setMessage(sb.toString())        .setPositiveButton("确定", new DialogInterface.OnClickListener() {                        @Override            public void onClick(DialogInterface dialog, int which) {                // TODO Auto-generated method stub                finish();            }        }).create();        dialog.show();    }        /**     * 更新版本     */    public void doNewVersionUpdate(){        int verCode = this.getVerCode(this);        String verName = this.getVerName(this);        StringBuffer sb = new StringBuffer();        sb.append("当前版本:");        sb.append(verName);        sb.append(" Code:");        sb.append(verCode);        sb.append(",发现版本:");        sb.append(newVerName);        sb.append(" Code:");        sb.append(verCode);        sb.append(",是否更新");        Dialog dialog = new AlertDialog.Builder(this)        .setTitle("软件更新")        .setMessage(sb.toString())        .setPositiveButton("更新", new DialogInterface.OnClickListener() {                        @Override            public void onClick(DialogInterface dialog, int which) {                // TODO Auto-generated method stub                pd = new ProgressDialog(MainActivity.this);                pd.setTitle("正在下载");                pd.setMessage("请稍后。。。");                pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);                downFile("http://10.0.2.2:8080/ApkUpdateService/ApkUpdateAndroid.apk");            }        })        .setNegativeButton("暂不更新", new DialogInterface.OnClickListener() {                        @Override            public void onClick(DialogInterface dialog, int which) {                // TODO Auto-generated method stub                finish();            }        }).create();        //显示更新框        dialog.show();    }        /**     * 下载apk     */    public void downFile(final String url){        pd.show();        new Thread(){            public void run(){                HttpClient client = new DefaultHttpClient();                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(),UPDATE_SERVERAPK);                        fileOutputStream = new FileOutputStream(file);                        byte[] b = new byte[1024];                        int charb = -1;                        int count = 0;                        while((charb = is.read(b))!=-1){                            fileOutputStream.write(b, 0, charb);                            count += charb;                        }                    }                    fileOutputStream.flush();                    if(fileOutputStream!=null){                        fileOutputStream.close();                    }                    down();                }  catch (Exception e) {                    // TODO Auto-generated catch block                    e.printStackTrace();                }            }        }.start();    }        Handler handler = new Handler() {        @Override        public void handleMessage(Message msg) {            super.handleMessage(msg);                            pd.cancel();            update();        }    };        /**     * 下载完成,通过handler将下载对话框取消     */    public void down(){        new Thread(){            public void run(){                Message message = handler.obtainMessage();                handler.sendMessage(message);            }        }.start();    }        /**     * 安装应用     */    public void update(){        Intent intent = new Intent(Intent.ACTION_VIEW);        intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory(),UPDATE_SERVERAPK))                , "application/vnd.android.package-archive");        startActivity(intent);    }}  
复制代码

 

地址:http://www.cnblogs.com/shmily0703/archive/2012/04/19/shmily_apk_update.html


<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述
http://www.lbrq.cn/news/2600407.html

相关文章:

  • 学习软件开发的网站关键词优化是什么意思?
  • 苏州企业名录黄页国外网站谷歌seo推广
  • 手机端网站模板山东网站建设
  • 微信web网站开发b站视频推广网站
  • 做网站做的好的公司站长工具手机综合查询
  • 做婚纱网站策划方案刷外链
  • wordpress顶部是什么seo优化网站优化排名
  • 湘潭做网站价格 d磐石网络关于搜索引擎的搜索技巧
  • 龙华区城市建设局网站百度网站客服
  • 表格网站滚动字体怎么做的seo外包公司怎么样
  • 营销型企业网站建设教案关键词排名手机优化软件
  • 集团门户网站建设费用科目免费seo推广软件
  • 怎么做视频还有网站吗最近韩国电影片
  • 深圳百度推广电话seo排名系统源码
  • 手机收藏网站代码视频号视频下载助手app
  • 做违法网站会怎样seo网站推广的主要目的是什么
  • 短视频营销策划方案范文百度关键词优化首选667seo
  • 产品设计工资一般多少seo网站有优化培训吗
  • 秦皇岛海三建设广州seo网站推广公司
  • 阿里巴巴做公司网站磁力屋 最好用
  • 权威的锦州网站建设seo职位招聘
  • 怎么查那些人输入做网站3分钟搞定网站seo优化外链建设
  • 上海网站设计kinglinkwindows优化大师是什么
  • 网站经营性备案百度广告推广价格
  • 网站建设委托外包协议网站权重查询
  • 长沙手机模板建站快排seo软件
  • 页面设计的网站九易建网站的建站流程
  • 铁岭做网站包括哪些中国职业培训在线官方网站
  • 信阳电子商务网站建设单页应用seo如何解决
  • wordpress代码添加文章字段栏目关键词查询优化
  • Could not load the Qt platform plugin “xcb“ in “无法调试与显示Opencv
  • AIDL学习
  • 《Python 实用项目与工具制作指南》· 2.3 导入
  • 福彩双色球第2025089期篮球号码分析
  • 编译旧版本的electron内核
  • RabbitMQ死信队列与消息幂等性实践指南