Skip to content

Commit ab7bf90

Browse files
author
1170762202@qq.com
committed
设置-国际化
1 parent 43caad7 commit ab7bf90

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ext {
55
minSdkVersion : 21,
66
targetSdkVersion : 28,
77
versionCode : 1,
8-
versionName : "1.1",
8+
versionName : "1.2",
99
]
1010

1111

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.zlx.module_base.base_util;
2+
3+
import android.content.Context;
4+
import android.content.pm.PackageInfo;
5+
import android.content.pm.PackageManager;
6+
7+
/**
8+
* Created by zlx on 2021/1/5 17:18
9+
* Email: 1170762202@qq.com
10+
* Description:
11+
*/
12+
public class AppUtil {
13+
/**
14+
* 获取版本号
15+
*
16+
* @return 当前应用的版本号
17+
*/
18+
public static String getVersion(Context context) {
19+
try {
20+
PackageManager manager = context.getPackageManager();
21+
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
22+
String version = info.versionName;
23+
return version;
24+
} catch (Exception e) {
25+
e.printStackTrace();
26+
return "无法获取到版本号";
27+
}
28+
}
29+
}

module-mine/src/main/java/com/zlx/module_mine/activity/SettingAc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import androidx.appcompat.app.AlertDialog;
1010

11+
import com.zlx.module_base.base_util.AppUtil;
1112
import com.zlx.module_base.base_util.LanguageUtil;
1213
import com.zlx.module_base.database.MMkvHelper;
1314
import com.zlx.module_base.base_api.util.ApiUtil;
@@ -56,6 +57,7 @@ public void initViews() {
5657
initData();
5758

5859
viewModel.getCache();
60+
tvVersion.setText(AppUtil.getVersion(this));
5961
}
6062

6163
private void initData() {

0 commit comments

Comments
 (0)