Reputation: 1239
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
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
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
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); } }
Upvotes: 1