26 Nov 2013

Create a flexible link to open Google Play or your own App from web browser in Android

Today I learnt a completely new thing as the title says it all, so I want to note it here for later uses.
So how to do?

In manifest.xml:
                      android:scheme="your-own-scheme" />
                 <action android:name="android.intent.action.VIEW" />
                 <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />

And your link should look like:
<a href="intent://;param2=value2#Intent;scheme=your-own-scheme;;end">OPEN APP OR GOOGLE PLAY</a>

The last thing is catching parameters in your com.your.package.ActivityName. In onCreate of the Activity:
 protected void onCreate(Bundle savedInstanceState) {
  Uri mUri = getIntent().getData();
  String value1 = mUri.getQueryParameter("param1");
  String value2 = mUri.getQueryParameter("param2");

That's all, bye xD!
P/S: Oh yeah, I just found this one too:, check it out!

No comments:

Post a Comment

Note: only a member of this blog may post a comment.