1

I am using below piece of code for getting target_url to my App.. every thing works fine but I want to pass json data from the target site to my app.. I have refered to Applinks.org documentation but there is no precise documentation on what i want.

    <head>
        <meta property="al:android:url" content="example://applinks" />
        <meta property="al:android:package" content="com.example" />
        <meta property="al:android:app_name" content="Example App" />
        <!-- Other headers -->
    </head>

On using below piece of code in my SplashActivity it throws NullPointer exception on bundle.getString("al_applink_data")..Am i refering to wrong bundle or my key/pair is wrong ???

        Bundle bundle=AppLinks.getAppLinkData(getIntent());
        Log.d("json i want",""+targetUrl+bundle.getString("al_applink_data"));

Please help!!!!

DRY Believer
  • 1,001
  • 11
  • 20
  • Please edit the question and add more information: Where is the `NullPointerException` thrown? Please do some debugging and establish which reference is `null`. – derabbink Jul 20 '15 at 09:30
  • yes .. I have edited the question where i get null pointer exception but is my key / pair right ... please help .. I have studied https://developers.facebook.com/docs/applinks that tells me to encode url.... could u please help me by giving an example... – DRY Believer Jul 21 '15 at 09:47

1 Answers1

1

The Bundle that is returned by the AppLinks.getAppLinkData(Intent) call already contains the contents of the "al_applink_data" data.

Hence, you don't need to fetch the data under the "al_applink_data" key by calling .getString("al_applink_data") on that bundle. Instead, you can directly fetch the information that is nested inside the "al_applink_data" section of the data.

For a complete example, check out the AppLinks/Bolts docs page on github:

Bundle applinkData = AppLinks.getAppLinkData(getIntent());
String id = applinkData.getString("id");
derabbink
  • 2,419
  • 1
  • 22
  • 47