Search code examples
androidurlandroid-intentparameterssend

Android Intent, send parameters?


So, I've been checking a couple of posts related to opening apps from the browser but my question is.

If I want to open the app but I also want to send a string in the link (the string will containt some passcode to open a certain part of the app that needs to load some specific information depending on the string I send)

How to achieve this? So far I can open the app and also have a fallback url if the app is not installed. Where can I put the parameter I'm trying to send?

In the example it opens the app, but how can I send say, a variable code="112233code"?

Take a QR code

Thanks!


Solution

  • Here's a question that might help you!

    I don't know how you open your app from the browser, but if you are using an intent like this:

     <a href="intent://whatever/#Intent;scheme=myapp;package=com.what.ever.myapp;end">Do Whatever</a> 
    

    Then you can enconde your parameter like this:

     <a href="intent://whatever/#Intent;scheme=myapp;package=com.what.ever.myapp;S.mycode=112233code;end">Do Whatever</a>
    

    This will pass an extra String called "mycode" with the value "112233code".

    In your Android app, you can recover those extras in the onCreate method in the following way:

    Bundle extras= getIntent().getExtras();
    if (extras != null){
        String mycode= extras.getString("mycode");
    }