Architect - Hitesh
Architect - Hitesh

Reputation: 1239

how to open smartphone default web browser app using QRcode deep linking

I am generating a QRcode which contain web link

So when anyone scans the QR code from any application weather from IOS or Android

Can we open that QRCode URL directs into smartphone's default web browser?

I have tried it through Deep linking but each and every scanner application only showing the scan result, however, I am not able to open WEB Browser

Upvotes: 2

Views: 1823

Answers (3)

Nitesh
Nitesh

Reputation: 7

First on onActivityResult of your QR Code scanning, you can check either result is a valid URL. If the is a valid URL, start your Intent to show your default Browser with that link.

Upvotes: 0

Dipendra Sharma
Dipendra Sharma

Reputation: 2640

For Android you can mark an Intent after scanning QRCode from device

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

Must check link is correct or not.

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

Upvotes: 0

Eselfar
Eselfar

Reputation: 3869

It doesn't matter if it's from a QR Code or not. Get the string in the QR Code, check if it's a valid URL and start a new intent.

public void openWebPage(String url) {
    Uri webpage = Uri.parse(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

See documentation here

Upvotes: 1

Related Questions