Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add extras to browsable intents from HTML

Let's take per say the following manifest:

<intent-filter>
    <data scheme="myscheme"
          host="myhost">
    </data>
    <action name="android.intent.action.VIEW">
    </action>
    <category name="android.intent.category.DEFAULT">
    </category>
    <category name="android.intent.category.BROWSABLE">
    </category>
</intent-filter>

I could launch the activity which under the above intent filter is declared by redirecting the browser to:

myscheme://myhost?param1=param1&param2=param2

However, I'm struggling with understanding if it is possible to do the same redirection, only with additional extras that would be received programmatically with:

myextra = getIntent().getStringExtra('myextra')

Any help would be very much appreciated.

like image 333
0rka Avatar asked Dec 05 '25 06:12

0rka


2 Answers

One could use "intent scheme URL" in order to send more information like extra objects and actions when redirecting to a custom intent scheme URL via javascript or HTML.

intent://foobar/#Intent;action=myaction1;type=text/plain;S.xyz=123;end

Although this method doesn't actually answer the question as the scheme part is destined to always be "intent", this is a possible way to send intents from browsers with extra object or actions.

See more extensive information in the following report:

http://www.mbsd.jp/Whitepaper/IntentScheme.pdf

Or use the chrome documentation:

https://developer.chrome.com/multidevice/android/intents

like image 85
0rka Avatar answered Dec 07 '25 22:12

0rka


This is how I overcome this issue,

I developed my own browser and made browsable like you do

Uri data = getIntent().getData();

if(data == null) { // Opened with app icon click (without link redirect)
    Toast.makeText(this, "data is null", Toast.LENGTH_LONG).show();
}
else { // Opened when a link clicked (with browsable)
    Toast.makeText(this, "data is not null", Toast.LENGTH_LONG).show();
    String scheme = data.getScheme(); // "http"
    String host = data.getHost(); // "twitter.com"
    String link = getActualUrl(host);
    webView.loadUrl(link);
    Toast.makeText(this,"scheme is : "+scheme+" and host is : "+host+ " ",Toast.LENGTH_LONG).show();
}

I think you are looking for this functions

data.getQueryParameter(String key);

like image 45
Berkay92 Avatar answered Dec 07 '25 21:12

Berkay92



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!