Skip to content

Commit

Permalink
添加后缀名apk
Browse files Browse the repository at this point in the history
  • Loading branch information
maning committed Apr 3, 2018
1 parent 326be40 commit a995945
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/maning/mnupdateapk/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public void onClick(View v) {
case R.id.btnDownload:
InstallUtils.with(this)
//必须-下载地址
.setApkUrl(Constants.APK_URL_03)
.setApkUrl(Constants.APK_URL_02)
//非必须,默认update
.setApkName("update")
//非必须-下载保存的路径
.setApkPath(Constants.APK_SAVE_PATH)
// .setApkPath(Constants.APK_SAVE_PATH)
//非必须-下载回调
.setCallBack(downloadCallBack)
//开始下载
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ public static void setDownloadCallBack(DownloadCallBack downloadCallBack) {

/**
* 取消下载
*
*/
public static void cancleDownload() {
isCancle = true;
}

/**
* 是否完成下载操作
*
* @return
*/
public static boolean isComplete() {
Expand All @@ -100,7 +100,8 @@ public static boolean isComplete() {

/**
* 初始化对象
* @param context 上下文
*
* @param context 上下文
* @return
*/
public static InstallUtils with(Context context) {
Expand All @@ -116,6 +117,7 @@ public static InstallUtils with(Context context) {

/**
* 设置保存的名字
*
* @param apkName
* @return
*/
Expand All @@ -126,6 +128,7 @@ public InstallUtils setApkName(String apkName) {

/**
* 设置下载地址
*
* @param apkUrl
* @return
*/
Expand All @@ -136,6 +139,7 @@ public InstallUtils setApkUrl(String apkUrl) {

/**
* 设置下载后保存的地址
*
* @param apkPath
* @return
*/
Expand All @@ -146,6 +150,7 @@ public InstallUtils setApkPath(String apkPath) {

/**
* 设置回调监听
*
* @param downloadCallBack
* @return
*/
Expand Down Expand Up @@ -179,9 +184,9 @@ public void startDownload() {
}
}
if (saveFile.getAbsolutePath().endsWith("/")) {
saveFile = new File(savePath + saveName);
saveFile = new File(savePath + saveName + ".apk");
} else {
saveFile = new File(savePath + File.separator + saveName);
saveFile = new File(savePath + File.separator + saveName + ".apk");
}
//开始下载
downloadStart();
Expand Down

0 comments on commit a995945

Please sign in to comment.