How can we remove deep link data from intent

Viewed 2298

This is how I process deep link in my Activity.

I was wondering, how can I remove it from intent, after I had finished process it?

@Override
public void onCreate(Bundle savedInstanceState) {
    Utils.updateTheme(this);

    super.onCreate(savedInstanceState);

    Uri uri = this.getIntent().getData();
    if (uri != null && uri.isHierarchical()) {
        if (Constants.INVESTING_DEEP_LINK_PATH.equals(uri.getPath())) {
            // Processing deep link...

            // How can I remove deep link information from intent, after
            // finished procesing deep link...
        }
    }
}

I want to prevent the same data, when this activity onCreate is being executed again. For example, during configuration changes.


According to OPs, we can use the following way, to remove deep link info from intent after finished processing. However, it will yield another problem.

@Override
public void onCreate(Bundle savedInstanceState) {
    Utils.updateTheme(this);

    super.onCreate(savedInstanceState);

    Uri uri = intent.getData();
    if (uri != null && uri.isHierarchical()) {
        if (Constants.INVESTING_DEEP_LINK_PATH.equals(uri.getPath())) {
            // Processing deep link...

            intent.setData(null);
            setIntent(intent);
        }
    }
}
  1. Press on the deep link in email.
  2. We are able to find the deep link from intent.
  3. Press home button
  4. Press on the deep link in email.
  5. Not able to find the deep link from intent anymore.
1 Answers
Related