Search code examples
androidintentfiltermain-activity

Android - open url in my app when my app is already opened


I'm trying to open a specific url with my app instead of browser. I have it working correctly except if my app is already open, the url doesn't open to the page specified.

My manifest file is as follows:

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="myapp"/>
<data android:scheme="http"/>
</intent-filter>

And I'm getting the intent data as:

Intent intent = getIntent();
Uri data = intent.getData();

But getIntent() returns the intent that started my activity, what if my url click didn't start my activity and the activity had already been created, how do I get the intent for whatever is resuming the app (so my specific path link). Is that even possible???

I am targeting Android 4.2.2


Solution

  • how do I get the intent for whatever is resuming the app (so my specific path link)

    Override onNewIntent() and use the Intent passed into it.