• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Need to open Notification.java activity when application close or minimize

Need to open Notification.java activity when application close or minimize

  • 1

    Votes: 0 0.0%
  • 1

    Votes: 0 0.0%

  • Total voters
    0
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.
 
Back
Top Bottom