Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back Button Failure After Extended Background Inactivity in App #24

Open
LaurentChennaouiDD opened this issue Nov 7, 2023 · 1 comment

Comments

@LaurentChennaouiDD
Copy link

LaurentChennaouiDD commented Nov 7, 2023

Initial activation of the back button through the SDK works successfully, with the button functioning correctly during normal background-foreground transitions. However, it has been observed that after a period of prolonged inactivity in the background, the back button ceases to respond.

After some investigation we discovered that you forget to save/restore the state of back button in/from the bundle:

// save the state
public void saveInstanceState(Bundle outState) {
       outState.putString("queueUrl", queueUrl);
       outState.putString("targetUrl", targetUrl);
       outState.putString("userId", uriOverrider.getUserId());
}

// restore the state
  private void readActivityExtras(Bundle savedInstanceState) {
       if (savedInstanceState == null) {
           Bundle extras = _context.getIntent().getExtras();
           if (extras == null) {
               queueUrl = null;
               targetUrl = null;
           } else {
               queueUrl = extras.getString("queueUrl");
               targetUrl = extras.getString("targetUrl");
               uriOverrider.setUserId(extras.getString("userId"));
               options = (QueueItEngineOptions)extras.getParcelable("options");
           }
       } else {
           queueUrl = (String) savedInstanceState.getSerializable("queueUrl");
           targetUrl = (String) savedInstanceState.getSerializable("targetUrl");
           uriOverrider.setUserId((String) savedInstanceState.getSerializable("userId"));
       }
       uriOverrider.setTarget(Uri.parse(targetUrl));
       uriOverrider.setQueue(Uri.parse(queueUrl));
 }


Instead of:

 // save the state
   public void saveInstanceState(Bundle outState) {
       outState.putString("queueUrl", queueUrl);
       outState.putString("targetUrl", targetUrl);
       outState.putString("userId", uriOverrider.getUserId());
       outState.putParcelable("options", options);          <-- HERE
   }

// restore the state
private void readActivityExtras(Bundle savedInstanceState) {
   if (savedInstanceState == null) {
      ...
   } else {
       queueUrl = (String) savedInstanceState.getSerializable("queueUrl");
       targetUrl = (String) savedInstanceState.getSerializable("targetUrl");
        uriOverrider.setUserId((String) savedInstanceState.getSerializable("userId"));
        options = (QueueItEngineOptions) savedInstanceState.getParcelable("options");        <-- HERE
   }

   ...
}
@Reza-0
Copy link
Contributor

Reza-0 commented Nov 24, 2023

Thank you for your post here.

We are not able to reproduce the issue you have reported.
Testing the SDK with different conditions and putting the app in the background for a long time (2+ hours), the back button is functioning as expected.
Would you please provide more information about how to reproduce the issue?

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants