Open Android Application from a Web Page

How to open android application from a webpage?

You might have a look at this: https://developer.android.com/training/app-indexing/deep-linking.html

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
<!-- note that the leading "/" is required for pathPrefix-->
<!-- Accepts URIs that begin with "example://gizmos”
<data android:scheme="example"
android:host="gizmos" />
-->
</intent-filter>

So your app will be started by this link:

<a href="example://gizmos">

How can I open a URL in Android's web browser from my application?

Try this:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);

That works fine for me.

As for the missing "http://" I'd just do something like this:

if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;

I would also probably pre-populate your EditText that the user is typing a URL in with "http://".

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);
}
}

Open android application from a web page

Try this:

Make your links look like this:

<a href="intent:#Intent;action=my_action;end">Link to my stuff</a>

Also have a look at Launch custom android application from android browser

Open android app from web

Edit your manifest file manually, you will find the file in Properties folder in your solution folder. Add the below code

<activity android:name="MainActivity">
<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="my_scheme" android:host="my_host" />
</intent-filter>
</activity>

You url in the browser will be :

<a href="intent://my_host/#Intent;scheme=my_scheme;end">Open Application</a><br>

You don't need package name if you have a unique scheme. The link will search for the scheme and open the application. I have tried this and it is working in Xamarin.

If you want a custom Action to be opened then this link will help you.

Opening Android application from website not working

I have found a solution to my problem. Whole internet is full of old examples.

Since chrome version 25, google made slight changes in app deep linking functionality. More info: https://developer.chrome.com/multidevice/android/intents

So my working code looks like this:

Intent filter in Android side:

<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="launcher"
android:path="/"
android:scheme="test" />
</intent-filter>

Web page html:

<a href="intent://launcher/#Intent;scheme=test;package=com.example.gediminas.myapplication;end">Launch app</a>

Open an Android app via a URL in the browser

There are several things in play here.

First, as Blackbelt noted, Android is case-sensitive, as are most programming languages and development environments. You would need to change this to be the proper case, following the documentation for those actions and categories:

<intent-filter>
<data android:scheme="myapp" android:host="hello"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

Second, not all Web browsers handle schemes like myapp:// the same. I am not aware of any law on the books in any jurisdiction forcing developers to honor them. There are three basic patterns that you will encounter:

  • Some browsers may handle them just fine

  • Some browsers will handle them when such URLs are used in links on a page, but not if the URL is typed in the address bar

  • Some browsers will not attempt to find an activity to handle them and just fail all the time

Google's preferred alternative is for you to use an http or https scheme, with a host and path that you control. Some browsers will always open the Web page, but others will check, see that there is an activity that advertises support for that URL, and give the user a choice of how to handle it. The "M" version of Android will provide further hooks ("App Links") that can bypass the chooser. Plus, other apps (e.g., text messaging clients, email clients) will typically make http links clickable, allowing users the choice of opening up your app, whereas few apps will know that myapp://hello is meaningful in the same way.

How To Open Web Page Within My App?

Add this to your code

webView.setWebViewClient(new WebViewClient(){

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
return true;
}
});


Related Topics



Leave a reply



Submit