Sneha Vijay Shinde
Lurker
below code mention in MyFirebaseMessageingService.java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
.......
@override
public void onMessageReceived(RemoteMessage remoteMessage) {
..............
ValidateCall(validateRingerRequestModel, new ApiCallback() {
@override
public void onResponse(boolean success, Object response) {
if (response != null) {
ValidateRingerResponseModel responseModel = (ValidateRingerResponseModel) response;
if (responseModel.status) {
Intent intent = new Intent(getApplicationContext(), Notification.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("data", model);
startActivity(intent);
}
}
}
});
}
"Notification" is a simple activity which shows some buttons with a click event actions. When application is running on foreground and notification comes in, then only activity starts but when application is closed or minimized or device is in sleep mode (battery saver mode or not used for long time), then above code gets executed but Notification.java activity is not opened.
That issue is faced by the devices with newer android versions like android 9, for older versions like android 6, it works.
Is the above code missing something or is there any other way that can work on all android versions?
Please suggest. Thanks.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
.......
@override
public void onMessageReceived(RemoteMessage remoteMessage) {
..............
ValidateCall(validateRingerRequestModel, new ApiCallback() {
@override
public void onResponse(boolean success, Object response) {
if (response != null) {
ValidateRingerResponseModel responseModel = (ValidateRingerResponseModel) response;
if (responseModel.status) {
Intent intent = new Intent(getApplicationContext(), Notification.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("data", model);
startActivity(intent);
}
}
}
});
}
"Notification" is a simple activity which shows some buttons with a click event actions. When application is running on foreground and notification comes in, then only activity starts but when application is closed or minimized or device is in sleep mode (battery saver mode or not used for long time), then above code gets executed but Notification.java activity is not opened.
That issue is faced by the devices with newer android versions like android 9, for older versions like android 6, it works.
Is the above code missing something or is there any other way that can work on all android versions?
Please suggest. Thanks.