How to get part of deep link in activity?

I have deep link which redirects user to activity. Deep link looks like “https://example.com/login/userId”. Is there any way I can get this userId in activity?

UPD. It seems I didn’t explain my question clearly. User clicks on link in his email and opens app with intent. And in this activity i need to get part deep link which was redirected him to this activity

Answer

Why don’t you just split the String? In your case, just split it as

mylink.split("/")[4];

If it is a url, toString() it.

Then pass it to whatever Activity using an Extra.

Now that you have updated it, send the url you recieved in your current Activity, then create the Intent for the Activity you’re about to launch, then send the url as a String and pass i to the Intent as a StringExtra, and then upon opening of the other Activity, get the link string via. getIntent().getStringExtra();. Then proceed to split.

Leave a Reply

Your email address will not be published. Required fields are marked *