最新一次版本提交
This commit is contained in:
82
7pokies/src/main/java/com/web/pokies7/MainActivity.java
Normal file
82
7pokies/src/main/java/com/web/pokies7/MainActivity.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.web.pokies7;
|
||||
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.web.base.LogUtils;
|
||||
import com.web.base.MainActivity2;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
|
||||
public class MainActivity extends MainActivity2 {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
initConfig();
|
||||
super.onCreate(savedInstanceState);
|
||||
initWinwdowLogoConfig();
|
||||
registerFCM();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册FCM
|
||||
*/
|
||||
private void registerFCM() {
|
||||
//订阅主题
|
||||
try {
|
||||
FirebaseMessaging.getInstance().subscribeToTopic("demo")
|
||||
.addOnCompleteListener(task -> {
|
||||
String msg = "Subscribed";
|
||||
if (!task.isSuccessful()) {
|
||||
msg = "Subscribe failed";
|
||||
}
|
||||
LogUtils.i("结果:"+msg);
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于修改大背景渐变色 不设置
|
||||
* 大背景就是 windows_color 的颜色
|
||||
* 不要动 都在 app_config.xml中修改
|
||||
*/
|
||||
private void initWinwdowLogoConfig() {
|
||||
setBackDrawables(R.drawable.big_bg);
|
||||
setImageView(getString(R.string.is_round).equals("1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础配置都在这里
|
||||
* 不要动 都在 app_config.xml中修改
|
||||
*/
|
||||
private void initConfig() {
|
||||
|
||||
//===========================以下是APP的配置信息 都写在 app_config.xml中==================================
|
||||
userId = Integer.parseInt(getString(R.string.userId));
|
||||
saveInt(MainActivity.this,"user_code",userId);
|
||||
saveInt(MainActivity.this,"version_code",getVersion());
|
||||
saveString(this, "base_url",getString(R.string.base_url));
|
||||
//网页的底部NavigationBar颜色
|
||||
saveInt(this, "style_color_int", getColor(R.color.style_color));
|
||||
//页面的大背景颜色
|
||||
saveInt(this, "windows_color_int", getColor(R.color.windows_color));
|
||||
//任务栏的文字颜色 0 黑 1白 默认黑
|
||||
saveInt(MainActivity.this,"is_white",Integer.parseInt(getString(R.string.is_white)));
|
||||
//===========================以上是APP的配置信息 都写在 app_config.xml中==================================
|
||||
}
|
||||
|
||||
|
||||
public int getVersion(){
|
||||
try {
|
||||
PackageManager packageManager = getPackageManager();
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
|
||||
int versionCode = packageInfo.versionCode; // 版本码
|
||||
return versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user