From the Chrome docs, I understand apps can be opened with the following URI
intent:
HOST/URI-path // Optional host
#Intent;
package=\[string\];
action=\[string\];
category=\[string\];
component=\[string\];
scheme=\[string\];
end;
I was wondering if I could open this URI from my app.
Example URI
intent:
//qr/json/%7B%22u%22%3A%22https%3A%2F%2Fprivacybydesign.foundation%2Fbackend%2Firma%2Fsession%2FvsRjkZF2B2H17sBWmVZe%22%2C%22irmaqr%22%3A%22disclosing%22%7D
#Intent;
package=org.irmacard.cardemu;
scheme=cardemu;
l.timestamp=1620907855707;
S.browser_fallback_url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dorg.irmacard.cardemu
;end
Since it look like a normal URI I thought I could open it like this:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("%EXAMPLE_URI%"));
startActivity(intent);
That gives me an ActivityNotFoundException
. What am I missing?
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=intent://qr/json/{"u":"https://privacybydesign.foundation/backend/irma/session/vsRjkZF2B2H17sBWmVZe","irmaqr":"disclosing"} pkg=org.irmacard.cardemu (has extras) }
The "intent:" syntax described in the Chrome docs is used to launch apps from a web page, Chrome will handle the href
and retrieve the params to launch apps via the Android Intent.
The scheme of the example URI you provided is intent://
, it is not handled by default.
if you want to handle the intent://
URI, you need to create a deep link
If you want to open a web page from your Android app, you can use the ACTION_VIEW action and specify the web URL in the intent data.
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);
}
}
// example
// openWebPage("https://privacybydesign.foundation/backend/irma/session/vsRjkZF2B2H17sBWmVZe")
more info about Intents and Intent Filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With