Java 未从firebase通知服务android 10调用前台服务
我已经实现了一个前台服务和一个广播侦听器来处理通知。当应用程序处于前台或在最近的应用程序中,但一旦应用程序被杀死,它就可以完美地工作。它停止工作了。请帮忙。这是我启动前台服务的代码Java 未从firebase通知服务android 10调用前台服务,java,android,firebase,foregroundnotification,Java,Android,Firebase,Foregroundnotification,我已经实现了一个前台服务和一个广播侦听器来处理通知。当应用程序处于前台或在最近的应用程序中,但一旦应用程序被杀死,它就可以完美地工作。它停止工作了。请帮忙。这是我启动前台服务的代码 //get values String theTitle = remoteMessage.getData().get("title"); String theMessage = remoteMessage.getData().get("message&qu
//get values
String theTitle = remoteMessage.getData().get("title");
String theMessage = remoteMessage.getData().get("message");
String callerName = remoteMessage.getData().get("sender_name");
String callerAvatar = remoteMessage.getData().get("sender_avatar");
String callerId = remoteMessage.getData().get("sender_uid");
String roomId = remoteMessage.getData().get("room_name");
String sessionId = remoteMessage.getData().get("call_session_id");
int notificationId = buildNotificationId(callerId);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Intent serviceIntent = new Intent(getApplicationContext(), HeadsUpNotificationService.class);
Bundle mBundle = new Bundle();
mBundle.putString(Common.CALL_NAME_INTENT, callerName);
mBundle.putString(Common.CALL_AVATAR_INTENT, callerAvatar);
mBundle.putString(Common.CALL_USER_ID_INTENT, callerId);
mBundle.putString(Common.CALL_TYPE_INTENT, dataType);
mBundle.putString(Common.CALL_SESSION_INTENT, sessionId);
mBundle.putString(Common.CALL_ROOM_INTENT, roomId);
serviceIntent.putExtras(mBundle);
ContextCompat.startForegroundService(getApplicationContext(), serviceIntent);
} else {
//build notification
Intent notificationIntent = new Intent(getApplicationContext(), CallCustomRinger.class);
//add flags and get extras from payload
notificationIntent.putExtra(Common.CALL_USER_ID_INTENT, callerId);
notificationIntent.putExtra(Common.CALL_NAME_INTENT, callerName);
notificationIntent.putExtra(Common.CALL_AVATAR_INTENT, callerAvatar);
notificationIntent.putExtra(Common.CALL_ROOM_INTENT, roomId);
notificationIntent.putExtra(Common.CALL_SESSION_INTENT, sessionId);
notificationIntent.putExtra(Common.CALL_TYPE_INTENT, dataType);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(notificationIntent);
}
还有什么我该做的吗。请帮忙。这快把我逼疯了