File tree Expand file tree Collapse file tree
src/main/java/io/github/javiewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ android {
99 applicationId " io.github.javiewer"
1010 minSdkVersion 15
1111 targetSdkVersion 24
12- versionCode 1
13- versionName " 1.1 "
12+ versionCode 4
13+ versionName " 1.2 "
1414 }
1515 buildTypes {
1616 release {
Original file line number Diff line number Diff line change 77public class Properties {
88
99 private String latest_version ;
10+ private int latest_version_code ;
1011
1112 private String changelog ;
1213
1314 public String getLatestVersion () {
1415 return latest_version ;
1516 }
1617
18+ public int getLatestVersionCode () {
19+ return latest_version_code ;
20+ }
21+
1722 public String getChangelog () {
1823 return changelog ;
1924 }
Original file line number Diff line number Diff line change @@ -154,14 +154,14 @@ public void run() {
154154 }
155155
156156 public void handleProperties (Properties properties ) {
157- String currentVersion ;
157+ int currentVersion ;
158158 try {
159- currentVersion = this .getPackageManager ().getPackageInfo (this .getPackageName (), 0 ).versionName ;
159+ currentVersion = this .getPackageManager ().getPackageInfo (this .getPackageName (), 0 ).versionCode ;
160160 } catch (PackageManager .NameNotFoundException e ) {
161161 throw new RuntimeException ("Hacked???" );
162162 }
163163
164- if (properties .getLatestVersion () != null && ! currentVersion . trim (). equals ( properties .getLatestVersion (). trim () )) {
164+ if (properties .getLatestVersionCode () > 0 && currentVersion < properties .getLatestVersionCode ( )) {
165165
166166 String message = "新版本:" + properties .getLatestVersion ();
167167 if (properties .getChangelog () != null ) {
You can’t perform that action at this time.
0 commit comments