Skip to content

Commit

Permalink
删除无用代码
Browse files Browse the repository at this point in the history
  • Loading branch information
maning committed Mar 30, 2018
1 parent bd453bb commit 2e4ae2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
compileSdkVersion 26
buildToolsVersion "25.0.2"

defaultConfig {
Expand Down
34 changes: 5 additions & 29 deletions app/src/main/java/com/maning/mnupdateapk/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -40,18 +38,14 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
context = this;

initViews();

}

private void initViews() {
tv_progress = (TextView) findViewById(R.id.tv_progress);
tv_info = (TextView) findViewById(R.id.tv_info);
btnDownload = (Button) findViewById(R.id.btnDownload);

//判断是不是最新版本
if (getVersionCode() > 1) {
//最新版本
tv_info.setText("当前版本是最新版本");
} else {
tv_info.setText("当前版本有更新");
}

}

public void otherPage(View view) {
Expand Down Expand Up @@ -107,22 +101,4 @@ public void onFail(Exception e) {
}).downloadAPK();
}

//版本号
public int getVersionCode() {
return getPackageInfo().versionCode;
}

private PackageInfo getPackageInfo() {
PackageInfo pi = null;
try {
PackageManager pm = getPackageManager();
pi = pm.getPackageInfo(getPackageName(),
PackageManager.GET_CONFIGURATIONS);
return pi;
} catch (Exception e) {
e.printStackTrace();
}
return pi;
}

}

0 comments on commit 2e4ae2d

Please sign in to comment.