Skip to content

Commit

Permalink
修改更新的判断方式
Browse files Browse the repository at this point in the history
  • Loading branch information
SplashCodes committed Oct 1, 2016
1 parent 35abefb commit a6a6b19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "io.github.javiewer"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.1"
versionCode 4
versionName "1.2"
}
buildTypes {
release {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/io/github/javiewer/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
public class Properties {

private String latest_version;
private int latest_version_code;

private String changelog;

public String getLatestVersion() {
return latest_version;
}

public int getLatestVersionCode() {
return latest_version_code;
}

public String getChangelog() {
return changelog;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ public void run() {
}

public void handleProperties(Properties properties) {
String currentVersion;
int currentVersion;
try {
currentVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
currentVersion = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Hacked???");
}

if (properties.getLatestVersion() != null && !currentVersion.trim().equals(properties.getLatestVersion().trim())) {
if (properties.getLatestVersionCode() > 0 && currentVersion < properties.getLatestVersionCode()) {

String message = "新版本:" + properties.getLatestVersion();
if (properties.getChangelog() != null) {
Expand Down

0 comments on commit a6a6b19

Please sign in to comment.