0

I have created an app which becomes logout after certain time period when app running in background. I have used a service and broadcast receiver in my main activity

  BroadcastReceiver mTimeOutReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.w(Constants.TAG, "mTimeOutReceiver onReceive"); // or whatever method used to update your GUI fields
            SetLogout(intent);
        }
    };

When this activity goes on Stop() I started service. This functinality working fine.

The problem is when app is open and if a GCM notification comes and user open that notification it switch user to a new activity and then previous activity goes on stop and after certain period app automatically goes logout even app is open as by notification in new activity. How to solve this issue?

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
Malik
  • 3
  • 3
  • keep a shared pref to check the application is completely closed. and in your service before logging out check that value. – Rajat Gupta Aug 02 '16 at 06:05
  • 1
    Looks like you need more control over the notification, in that case you should use data messages. Have a look at messages types here: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages – Arthur Thompson Aug 02 '16 at 16:23

0 Answers0