提交 5a45b7a9 authored 作者: shixiaochen's avatar shixiaochen

fix:修复更新悬浮窗方法崩溃问题;

上级 3dc45b7d
......@@ -244,7 +244,7 @@ public class WindowServiceNew extends Service implements View.OnTouchListener {
// update the notification
private void updateNotification(HashMap<String, Object> paramsMap) {
String notificationUpdateData = (String) paramsMap.get(Constants.KEY_UPDATE_NOTIFICATION_DATA);
assert notificationUpdateData != null;
if (notificationUpdateData != null) {
HashMap<String, String> notificationData = new Gson().fromJson(notificationUpdateData, HashMap.class);
if (notificationData != null) {
LogUtils.getInstance().d(TAG, "Updating the notification");
......@@ -269,12 +269,7 @@ public class WindowServiceNew extends Service implements View.OnTouchListener {
if (lastLoadTime != null) {
remoteViews.setTextViewText(R.id.tv_last_load_time, "最晚装货:" + lastLoadTime);
}
notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_logo)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomBigContentView(remoteViews)
.setContentIntent(pendingIntent)
.build();
notification = new NotificationCompat.Builder(this, CHANNEL_ID).setSmallIcon(R.drawable.ic_notification_logo).setStyle(new NotificationCompat.DecoratedCustomViewStyle()).setCustomBigContentView(remoteViews).setContentIntent(pendingIntent).build();
if (Build.VERSION.SDK_INT >= 34) {
startForeground(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
......@@ -282,6 +277,7 @@ public class WindowServiceNew extends Service implements View.OnTouchListener {
}
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论