Launching Custom Android Application from Android Browser/Chrome

Launching custom Android application from Android browser / Chrome

You need to set it up like this :

<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:host="example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
</intent-filter>

Notice that in your case, you would need to use android:pathPrefix instead of android:path.

Launch Android App from WEB browser

Guess I got my own answer after some more research:

It only works in Google Chrome but does the job in my case:

Links should look like:

<a href="intent://invoice/#Intent;scheme=company;package=company.printapp;S.doctype=FRA;S.docno=FRA1234;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end">PRINT INVOICE</a>

In the AndroidManifest.xml the important part is:

...

package="company.printapp"
...

<!-- Allow web apps to launch My App -->
<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="company" android:host="invoice" android:path="/"/>
</intent-filter>

And finally this is how I get the parameters I pass in the Intent link (doctype and docno):

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bundle parametros = getIntent().getExtras();
if (parametros != null){
String Doctype = parametros.getString("doctype");
String DocNo = parametros.getString("docno");
TextView textView = (TextView) findViewById(R.id.DocNo);
textView.setText(DocNo);
BluetoothPrint(Doctype,DocNo);
}
}


Related Topics



Leave a reply



Submit