Skip to content

Back Button Failure After Extended Background Inactivity in App #24

@LaurentChennaouiDD

Description

@LaurentChennaouiDD

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
   }

   ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions