Skip to content

Commit

Permalink
设置-国际化
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 5, 2021
1 parent 43caad7 commit ab7bf90
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext {
minSdkVersion : 21,
targetSdkVersion : 28,
versionCode : 1,
versionName : "1.1",
versionName : "1.2",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.zlx.module_base.base_util;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
* Created by zlx on 2021/1/5 17:18
* Email: [email protected]
* Description:
*/
public class AppUtil {
/**
* 获取版本号
*
* @return 当前应用的版本号
*/
public static String getVersion(Context context) {
try {
PackageManager manager = context.getPackageManager();
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
String version = info.versionName;
return version;
} catch (Exception e) {
e.printStackTrace();
return "无法获取到版本号";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import androidx.appcompat.app.AlertDialog;

import com.zlx.module_base.base_util.AppUtil;
import com.zlx.module_base.base_util.LanguageUtil;
import com.zlx.module_base.database.MMkvHelper;
import com.zlx.module_base.base_api.util.ApiUtil;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void initViews() {
initData();

viewModel.getCache();
tvVersion.setText(AppUtil.getVersion(this));
}

private void initData() {
Expand Down

0 comments on commit ab7bf90

Please sign in to comment.