Deep link does not work with Branch - android

This is what I got in my Manifest:
<activity
android:name=".activities.VidyoSampleActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_hjyeOhAByhF1x452yXtuEjdpCzhMiEAB" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="c13e89c059c32c08041932f2d48b4e5bf1054b4a" />
I am using this version: compile 'io.branch.sdk.android:library:2.+'
And I do in my Application class the initialization.
This is the url scheme I have set on my dashboard.branch.io: facetalk://
But when I try this link:
facetalk://facetalk.vidyo-nl.com/mobile.html?key=saETMuvxjeW2akgzbyt46Xffio&guestname=Test123&secure=yes
It does nothing.
Why is that?
I even created the code for branch from the Fabric AndroidStudio plugin. and it still doesn't work. What am I doing wrong?
Let me know if more info is needed
PS: If I remove from the intent filter this:
android:host="open"
It will work. But I don't think it goes via branch like that. cause it doesn't enter this:
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchReferralInitListener() {
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
Log.i("BranchConfigTest", "deep link data: " + referringParams.toString());
}
}
}, this.getIntent().getData(), this);
After adding some logs. I found out that this is getting logged, when the app starts the first time:
11-16 12:18:45.237: I/BranchConfigTest(25065): deep link data: {"+is_first_session":false,"+clicked_branch_link":true,"room":"DpoxihjuKKKE24FAP2ByTILdZsg","guestname":"John","secure":"true","$marketing_title":"Join Conference","$one_time_use":false,"~creation_source":1,"~feature":"marketing","~id":"325753563785928408","~marketing":true,"+click_timestamp":1479295095,"+match_guaranteed":true,"~referring_link":"https:\/\/facetalk.app.link\/join?room=DpoxihjuKKKE24FAP2ByTILdZsg&guestname=John&secure=true"}
I don't understand how this is being shown? Cause I just launch the app, I did not press any link.
Also when I press on a link I created, this does not get called anymore

Alex from Branch.io here: you need to create a Branch link and test with that URL. Directly entering the deep link path with the URI scheme is not the correct implementation and (as you discovered) will not work.

The Branch.io Integration shows that I need to add the intent as this:
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
But that did not work for me for branch 2.x.
This was the way I was able to add the intent:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="facetalk.app.link" />
</intent-filter>

Related

Flutter - oauth2 - Android - redirecturi not working

I have an issue with a flutter implementation on Android. On iOS it works fine.
Here is my AndroidManifest.xml:
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp"/>
</intent-filter>
I defined the SpotifyClient like that:
class SpotifyOAuth2Client extends OAuth2Client {
SpotifyOAuth2Client({required String redirectUri, required String customUriScheme}) :
super(
authorizeUrl: 'https://accounts.spotify.com/authorize',
tokenUrl: 'https://accounts.spotify.com/api/token',
redirectUri: redirectUri,
customUriScheme: customUriScheme) {
this.accessTokenRequestHeaders = {'Accept': 'application/json'};
}
}
And here is where I try to call the client:
OAuth2Client client = SpotifyOAuth2Client(
redirectUri: 'com.mycomp.myapp://callback',
customUriScheme: 'com.mycomp.myapp');
var authResp = await client.requestAuthorization(
clientId: 'huhuhuhuhuhuhuhuhu',
customParams: {'show_dialog': 'true'},
scopes: ['user-read-private', 'user-read-playback-state', 'user-modify-playback-state', 'user-read-currently-playing', 'user-read-email']);
print(authResp.code);
The app is correctly triggering the authorization to Spotify. I get to log in and accept on the web browser.
Then I get redirected to myApp but nothing happens. The print(authResp.code) (and of course everything following) above never fires.
Again, on iOS I have no issue.
I have been trying many thing but with no success. Any help would be much appreciated!
After many trials, I have been able to fix the issue.
Hope it can help somebody else.
Adding the following activity (and not only intent-filter in an existing activity) made the trick:
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp" android:host="callback" />
</intent-filter>
</activity>
hi can you share the code? my code no works when try to add another activity
<activity
android:name="io.flutter.embedding.android.SplashScreenDrawable">
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp" android:host="callback" />
</intent-filter>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
</activity>

Firebase dynamic link not opening the app

I have developed an android app locally on my device (app not yet on android play store). I have the following logic to get deep link in MainActivity.
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, null)
.addApi(AppInvite.API)
.build();
// Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
// would automatically launch the deep link if one is found.
boolean autoLaunchDeepLink = false;
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
.setResultCallback(
new ResultCallback<AppInviteInvitationResult>() {
#Override
public void onResult(#NonNull AppInviteInvitationResult result) {
if (result.getStatus().isSuccess()) {
// Extract deep link from Intent
Intent intent = result.getInvitationIntent();
String deepLink = AppInviteReferral.getDeepLink(intent);
Toast.makeText(getApplicationContext(), deepLink, Toast.LENGTH_LONG).show();
// Handle the deep link. For example, open the linked
// content, or apply promotional credit to the user's
// account.
// ...
} else {
Log.d(TAG, "getInvitation: no deep link found.");
}
}
});
I built some dynamic links using Firebase console and open in mobile browser. But it is not opening my app and reaching to line String deepLink = AppInviteReferral.getDeepLink(intent);
Instead it is opening the URL in mobile browser itself.
How to open the app and handle deep link in activity while using firebase dynamic link??
Edit:
I have intent filter in the manifest file.
<activity android:name="MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="example.com" android:scheme="http"/>
<data android:host="example.com" android:scheme="https"/>
</intent-filter>
</activity>
Action View and Action Main both are of different Intent category. So, you need to put them in different blocks like this:
<activity android:name=".DynamicLinkActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="example.com"
android:scheme="http" />
<data
android:host="example.com"
android:scheme="https" />
</intent-filter>
</activity>
Alternatively, you could also provide the data in your intent-filter, like stated in the "regular" deep links doc (https://developer.android.com/training/app-indexing/deep-linking.html)
The intent filter would then look like the following :
<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="https://XXYYZZ42.app.goo.gl/" // <- Replace with your deep link from the console
android:scheme="https"/>
</intent-filter>
That said link can be obtained in your console, right here :
EDIT : Added the picture to show where to find this link
Update January 2019
Ensure that you have added the SHA256 certificate fingerprint for your app into your project in the Firebase console.
Add the below code in the AndroidManifest.xml under the activity which you want the dynamic link to lunch:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="mydomainname.page.link" android:scheme="http"/>
<data android:host="mydomainname.page.link" android:scheme="https"/>
</intent-filter>
Remove android:autoVerify="true" if you have Android 6.0 (API level 23) and below or the app will crash.
As explained in another answer, your intent filter seems to have some problems. Also your url may have some problems. When I was playing with those, I had created faulty URL to FireBase web site without noticing it. It is possible to test you code by opening the whole url in your app. I wrote all urls to be tested to an email and sent to myself, open in the device and started clicking. After that you can create the url you want in FireBase. Below are few examples (typos and other errors possible):
If you clicked this url on your device:
https://<myapp>.app.goo.gl/?link=https://mysite.fi/112972&apn=com.mydomain.myapp
and had this in you manifest:
<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="https"
android:host="mysite.fi"
android:pathPattern=".*" />
</intent-filter>
It should open https://mysite.fi/112972 in your app (com.mydomain.myapp) and if you opened the link on your PC, it would open https://mysite.fi/112972 in the browser.
If you opened this url in your device:
https://<myapp>.app.goo.gl/?link=https://mysite.fi/112972&apn=com.mydomain.myapp&al=myscheme://mydeeplink/112972&afl=http://fallback.fi
and had this in you manifest:
<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="myscheme"
android:host="mydeeplink"
android:pathPattern=".*" />
</intent-filter>
It would open myscheme://mydeeplink/112972 in your app (com.mydomain.myapp). You would need to have code for handling it. If the app is not installed, it would open http://fallback.fi in your browser. On the PC it would still open https://mysite.fi/112972.
(edit 19.3.2018) It seems that Firebase does not fully support 'al=' anymore. The code works, but it is missing from the documentation and Firebase console generated urls.
I had the same problem with deep links not working and the former answers wasn't helping. What did the trick was splitting the "data" tag like this:
Instead of:
<data android:host="example.com" android:scheme="http"/>
<data android:host="example.com" android:scheme="https"/>
Do this:
<data android:host="example.com"/>
<data android:scheme="http"/>
<data android:scheme="https"/>
Hope that will help anyone else :)

Android Intents with Chrome: "Item not found"

I'm trying to open my app from Chrome but it doesn't work for me..
Here's the official (very limited) documentation:
Android Intents with Chrome
I've found a bunch of similar questions but none of the solutions seem to work for me - also, the answers are a bit fragmented so I'm looking for the complete answer with example. I'd be happy to post my full solution as soon as we found it :)
Launching an Android Application from the Browser
Open Android app from URL using intent-filter not working
Here's what I got now:
AndroidManifest.xml:
<activity android:name=".ActMain" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="http" />
<data android:scheme="https" />
<data android:scheme="sharedr" />
<data android:host="pocketr.rejh.nl" />
<data android:pathPattern="/.*" />
</intent-filter>
</activity>
Javascript (it builds the intent link when user clicks on an element):
var url = "http://icerrr.rejh.nl/"
var title = "Example"
var intenturl = "intent://sharedr/#Intent;"
+ "package=com.rejh.sharedr;"
+ "S.action=share;"
+ "S.type=url;"
+ "S.title="+ app.helpers.encodeURIComponent(title) +";"
+ "S.url="+ app.helpers.encodeURIComponent(url) +";"
+ "end";
alert(intenturl); // for debugging
try {
window.location.href=intenturl;
} catch(e) { alert(JSON.stringify(e)); }
I get the following 'link' from this function:
intent://sharedr/#Intent;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end
Human-readable:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
So this works as in: it opens the Play Store and shows "Item not found" and a Refresh button. So it opens an activity but not the right one..
The website I'm trying to fire this from is http://pocketr.rejh.nl
Help?
The full answer
As pointed out by Mattia below (and I just figured this out myself but found the answer waiting for me... :P)
First of all: I forgot to include the 'scheme=sharedr' in my intent link:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
Should be (notice the 2nd line):
intent://sharedr/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
Then, in the android manifest:
<activity android:name=".ActMain" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="sharedr" android:host="sharedr" android:path="/"/>
</intent-filter>
</activity>
Where 'android:scheme="sharedr"' is the 'scheme=sharedr' part and 'android:host="sharedr"' corresponds to 'intent://sharedr/'
Thanks!
You specify sharedr as host but the host configured in your AndroidManifest.xml is pocketr.rejh.nl. Also you didn't specify the scheme.
The URL fixed is this:
intent://pocketr.rejh.nl/#Intent;scheme=sharedr;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end
Human-readable:
intent://pocketr.rejh.nl/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end

Intent Filter to Launch My Activity when custom URI is clicked

I am trying to allow a URI to be registered to open up with my app. Like the PatternRepository on the Blackberry and the CFBundleURLName/CFBundleURLSchemes on the iPhone. How do I achieve the same results on the Android?
The system will be sending emails with the following link: myapp://myapp.mycompany.com/index/customerId/12345. The idea is that the user should be able to click on the link to open up the customer activity in the application.
I've tried numerous suggestions from other SO posts but I cannot get the OS to recognize the pattern and open my app.
On The Gmail app it looks like this: myapp://myapp.mycompany.com/index/customerId/12345. It recognizes and underlines the myapp.mycompany.com/index/customerId/12345 portion of the link and it opens it in a browser. The myapp:// part is not linkified.
The standard mail application treats the entire link as plain text.
What am I missing here?
PS: I've already looked at
How to implement my very own URI scheme on Android
and How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?
The Manifest:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="2"
android:versionName="0.0.8"
package="com.mycompany.myapp.client.android">
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:label="#string/app_name"
android:name="myappApplication"
android:icon="#drawable/ic_icon_myapp"
android:debuggable="true">
<activity
android:label="My App"
android:name=".gui.activity.LoginActivity"
label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity" >
<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="myapp"/>
</intent-filter>
</activity>
<activity android:name=".gui.activity.CustomerDetailActivity"/>
<activity android:name=".gui.activity.CustomerImageViewerActivity" />
<activity android:name=".gui.activity.CustomerListActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.HomeActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.AboutActivity" android:configChanges="orientation|keyboardHidden"/>
<activity android:name=".gui.activity.AccountActivity" android:configChanges="orientation|keyboardHidden" />
</application>
</manifest>
The final solution was a hacky workaround to cover all bases. The email now also contains an attachment with an extension that is registered to open with the app.
AndroidManifest.xml :
<activity android:name=".gui.activity.CustomerDetailActivity" >
<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="https"
android:host="myapp.mycompany.com" />
</intent-filter>
<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="myapp"
android:host="myapp.mycompany.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/myapp" />
</intent-filter>
</activity>
When I was working on OAuth with Google Calendar, I had to add this filter to the Activity I wanted to receive the callback:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="yourapp" android:host="goog"></data>
</intent-filter>
The when the browser invoked the yourapp://goog URL, it would return to my Activity.
You can get around the issue of GMail not linking non-standard protocols by using a standard HTTP URL with a 302 redirect. You could either set it up on your website's webserver or application server, or for the quick and dirty test you could use a URL shortener like http://bit.ly.
This is solution for me. Thanks #DanO
<intent-filter>
<data android:scheme="yourcustomname"/>
<data android:host="*"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Have you dried adding a category to your intent-filter:
<category android:name="android.intent.category.BROWSABLE" />
You could always try sending your emails using HTML and then use an <a> tag around to create the URL. I don't think there is a way to change the way the Gmail or Mail parse their text, since they probably use the Linkify class.
Another option would be use use http:// and then just parse for a specific custom subdomain which would provide your users with the option to open in a browser or your application.
I just ran into this also, but for standard http: scheme urls. Gmail doesn't appear to add any categories to the Intent. Now I check for BROWSABLE, but I also include a check for !intent.hasCategories() and allow that to go through as well.

android custom url scheme..?

Im trying to create my own url scheme so my android app can get called via an URL but for now I dont have a success.
Im trying to have this url to work : cedemo://com.cedemo.scan?X=toto
Here is part of my manifest file :
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.GALLERY" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
Does anyone can help telling me what is wrong ?
Also, if someone find what is wrong, can someone tell me how I read the "X" variable from inside the android code from my app ?
Update:
Update: I did the modification of the action (as advised in one of the answers) and it's worked fine. The thing is that I still cannot get the url variable value. Here is the code I tried.
final Intent intent = getIntent();
final String myScheme=intent.getScheme();
final Bundle myBundle=intent.getExtras();
final boolean inContestKey;
if (myBundle != null) {
inContestKey=myBundle.containsKey("inContest");
}
final Uri myURI=intent.getData();
final String value;
if (myURI != null) {
value = myURI.getQueryParameter("inContest");
}
But I receiving null from all the functions… what else can i do?
May be I should explain better the context of my software:
My software is started
My software launch then the browser
the user click a link in the browser and the browser go to the url scheme, back to the software with a variable "X" (for example)
the software should read the variable "X"
But in my case : myScheme, myBundle, myURI are set to null.
Any ideas ?
Update:
I found the answer is that you have to be in the main activity to do that.
I think the problem is with the Action you defined.
There is a "android.intent.action.VIEW" which is what I think you want.
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<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="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
Try that and I bet will resolve correctly. I only made this assumption because you included the browsable category which is usually used by the Browser, which does not know of any of your custom actions. If you do want the GALLERY action as you have implied then just create 2 filters
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.GALLERY" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
<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="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
So within the contents of your activity you can do something like:
// Value should be "toto" as in your example
String value = getData().getQueryParameter("X");
What finally fixed things for me was changing the order of the XML elements. Specifically, swapping the data and action rows so data is before action made it start working.
<intent-filter>
<data android:scheme="myappname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
And for completeness, my link in the html is "myappname://noop".
One more thing, i would like to throw light. Initially it was not working for me because i was using Main/Launcher tags before View/Default/Browsable/data.
Once i changed the order it started working fine.
i.e Initially not working code
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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="myapp" />
</intent-filter>
correct code order
<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="myapp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
and way to test for android is very simple.
Make any html file insert
test to launch myapp <br /><br />
just open this html file and click on test to .... :-)

Categories

Resources