Home > Android > Android:Run native app via Browser

Android:Run native app via Browser

Here is a memo in my recent project for how to run our native app from web app .

  • html

Create an action like bellow.

location.href = "myschemename://myhost/app.do?p1='1'&p2='2'";

(※ app.do makes no sense)

  • manifest

Use an <intent-filter> with a <data> element.
then specify the scheme and host in it for our web app to invoke.

 <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:scheme="myscheme" android:host="myhost" />
  • java

You can use getIntent().getData()which returns a Uri object , then get the parameter from it.

if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = getIntent().getData();
String p1 =  uri.getQueryParameter("p1");
String p2 =  uri.getQueryParameter("p2");


Categories: Android
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: