Android版本检测\自动更新
来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:38 点击:次
package com.hiyo.game.pdk.tool;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.util.Log;
import android.webkit.URLUtil;
import com.hiyo.game.pdk.activity.R;
/**
* Android AutoUpdate.
*
* lazybone/2010.08.20
*
* 1.Set apkUrl.
*
* 2.check().
*
* 3.add delFile() method in resume()\onPause().
*/
public class MyAutoUpdate {
public Activity activity = null;
public int versionCode = 0;
public String versionName = "";
private static final String TAG = "AutoUpdate";
private String currentFilePath = "";
private String currentTempFilePath = "";
private String fileEx = "";
private String fileNa = "";
private String strURL = "http://127.0.0.1:81/ApiDemos.apk";
private ProgressDialog dialog;
public MyAutoUpdate(Activity activity) {
this.activity = activity;
getCurrentVersion();
}
public void check() {
if (isNetworkAvailable(this.activity) == false) {
return;
}
if (true) {// Check version.
showUpdateDialog();
}
}
public static boolean isNetworkAvailable(Context ctx) {
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.util.Log;
import android.webkit.URLUtil;
import com.hiyo.game.pdk.activity.R;
/**
* Android AutoUpdate.
*
* lazybone/2010.08.20
*
* 1.Set apkUrl.
*
* 2.check().
*
* 3.add delFile() method in resume()\onPause().
*/
public class MyAutoUpdate {
public Activity activity = null;
public int versionCode = 0;
public String versionName = "";
private static final String TAG = "AutoUpdate";
private String currentFilePath = "";
private String currentTempFilePath = "";
private String fileEx = "";
private String fileNa = "";
private String strURL = "http://127.0.0.1:81/ApiDemos.apk";
private ProgressDialog dialog;
public MyAutoUpdate(Activity activity) {
this.activity = activity;
getCurrentVersion();
}
public void check() {
if (isNetworkAvailable(this.activity) == false) {
return;
}
if (true) {// Check version.
showUpdateDialog();
}
}
public static boolean isNetworkAvailable(Context ctx) {
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>