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?