| | |
| | | package com.hdl.photovoltaic; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.ActivityManager; |
| | | import android.app.AlarmManager; |
| | | import android.app.Application; |
| | | import android.app.PendingIntent; |
| | | import android.app.NotificationChannel; |
| | | import android.app.NotificationManager; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.res.Configuration; |
| | | import android.graphics.Color; |
| | | import android.os.Build; |
| | | import android.os.Handler; |
| | | import android.os.LocaleList; |
| | |
| | | import com.hdl.sdk.link.core.connect.HDLUdpConnect; |
| | | import com.hdl.sdk.link.core.utils.QueueUtils; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | //import com.umeng.analytics.MobclickAgent; |
| | | //import com.umeng.commonsdk.UMConfigure; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | SharedPreUtils.init(this); |
| | | getAppLanguage(); |
| | | //预创建脚本json文件夹 |
| | | HdlFileLogic.getInstance().createHdlESLocalJsonDirectory(); |
| | | HdlFileLogic.getInstance().createHdlDeviceModelLocalJsonDirectory(); |
| | | init(); |
| | | |
| | | |
| | |
| | | // //9.初始化网络工具 |
| | | // NetWorkUtil.init(this); |
| | | initAutoSize(); |
| | | // //初始化极光推送 |
| | | // initJPush(); |
| | | //初始化极光推送 |
| | | initJPush(); |
| | | //谷歌原生fcm推送 |
| | | // 检查 Google Play Services 后再初始化 FCM |
| | | if (isGooglePlayServicesAvailable(this)) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化友盟SDK,抓闪退日志 |
| | |
| | | Log.d("FCM", "FCM Token: " + token); |
| | | |
| | | // 保存 token |
| | | saveFCMToken(token); |
| | | saveToken(token); |
| | | }); |
| | | |
| | | // // 订阅主题(可选) |
| | |
| | | * |
| | | * @param token 令牌 |
| | | */ |
| | | public void saveFCMToken(String token) { |
| | | public void saveToken(String token) { |
| | | if (TextUtils.isEmpty(token.trim())) { |
| | | return; |
| | | } |
| | | UserConfigManage.getInstance().setPushToken(token); |
| | | UserConfigManage.getInstance().Save(); |
| | | |
| | | // // 发送到服务器 |
| | | // sendTokenToServer(token); |
| | | } |
| | | |
| | | |
| | |
| | | return this; |
| | | } |
| | | } |
| | | |
| | | // private void createNotificationChannel() { |
| | | // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| | | // NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); |
| | | // // 通知渠道的id。 |
| | | // String id = "ali_push_channel"; |
| | | // // 用户可以看到的通知渠道的名字。 |
| | | // CharSequence name = "notification channel"; |
| | | // // 用户可以看到的通知渠道的描述。 |
| | | // String description = "notification description"; |
| | | // int importance = NotificationManager.IMPORTANCE_HIGH; |
| | | // NotificationChannel mChannel = new NotificationChannel(id, name, importance); |
| | | // // 配置通知渠道的属性。 |
| | | // mChannel.setDescription(description); |
| | | // // 设置通知出现时的闪灯(如果Android设备支持的话)。 |
| | | // mChannel.enableLights(true); |
| | | // mChannel.setLightColor(Color.RED); |
| | | // // 设置通知出现时的震动(如果Android设备支持的话)。 |
| | | // mChannel.enableVibration(true); |
| | | // mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); |
| | | // // 最后在notificationmanager中创建该通知渠道。 |
| | | // mNotificationManager.createNotificationChannel(mChannel); |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 重启app |
| | | */ |
| | | private void restartApp(Context context) { |
| | | try { |
| | | MobclickAgent.onKillProcess(context); |
| | | // MobclickAgent.onKillProcess(context); |
| | | SystemClock.sleep(300); |
| | | Intent intent = new Intent(context, StartActivity.class); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); |
| | | context.startActivity(intent); |