Android intent-filter not filtering pathPrefix - android

We have lots of activities, but two were designed to start optionally from a URL using intent-filter. These two activities have the same scheme and host, but they have different pathPrefix. When we used a URL that matched one of these, it would just show our app once along with any browsers. Now, it is showing our app for any URL that matches the scheme. What we most care about is that its showing our app twice in our supported testing scenarios.
Does anyone have a workaround or know that this is a bug since we used to get the desired behavior? Does someone know what we changed that broke this (we have switched API level, build tools version, etc).
<activity
android:name="com.ConfigurationLoadingActivity"
android:label="#string/title_activity_configuration_loading" android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:noHistory="true" >
<intent-filter android:label="#string/app_name">
<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="#string/app_intent_filter_host" android:pathPrefix="/mobilecloud/configuration" />
</intent-filter>
</activity>
<activity
android:name="com.SchoolSelectionActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="#string/title_activity_school_selection"
android:noHistory="true" >
<intent-filter android:label="#string/configuration_list">
<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="#string/app_intent_filter_host" android:pathPrefix="/mobilecloud/cloud" />
</intent-filter>
</activity>

Related

Android 6 - cannot open app url from chrome

I had setup intent filter in manifest.xml, such as follows:
<activity
android:name="indexgifto.android.ui.viewcontrollers.SplashScreenActivity"
android:label="#string/application_name"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustNothing"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="portrait" >
<intent-filter>
<data android:scheme="gifto"/>
<data android:scheme="http" />
<data android:host="www.gifto.net"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
When I execute 'am start http://www.gifto.net/go.php?c=xlh201' application successfully opens with required data. But, when same URL opened via Chrome, just server page opens. In the android 4 in both cases my app was able to start from this url. What I must fix in android 6?
Chrome for Android, versions 25 and later, you should implement a user gesture to launch the app via a custom scheme, or use the “intent:” syntax described in this article.
https://developer.chrome.com/multidevice/android/intents
this worked for me you to try once if worked for u.
<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:host="www.youtube.com" android:scheme="http" android:pathPrefix="http"></data>
</intent-filter>

Open Android App with custom URL scheme

this questions has been asked in a similar way like a hundred times, though I still cannot find a proper answer to get my app to work the way I want. Maybe this is not possible which would be a valid answer of course.
I have an activity defined as follows in my app:
<activity
android:name="MyActivity"
android:label="MyActivityLabel"
android:launchMode="singleTask" >
<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="MyActivityCustomUrlScheme" />
</intent-filter>
</activity>
When I start my App in the emulator and then open the browser and type a URL like:
MyActivityCustomUrlScheme://mycustomHost.com?someOptions
the only thing happening is that chrome tries googling for it, which is not what I want. If I send myself an SMS with this scheme, the scheme inside is not recognised as such and not clickable :(
I want to do that, because I already have an iOS App in the store, which uses the scheme MyActivityCustomUrlScheme://mycustomHost.com?someOptions and it would be a lot of hazel to change it everywhere, as users get this url send by email or SMS. I'd be really thankful if someone can help me out on this problem.
Try to use definition of host :
<activity android:name="MyActivity"
android:label="MyActivityLabel"
android:launchMode="singleTask">
<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="MyActivityCustomUrlScheme" android:host="mycustomHost.com" />
</intent-filter>
</activity>

Android Deeplinking not working with multiple schemes

I am stuck with the following scenario. I defined the following deep link intent filters in the AndroidManifest.xml
Expected behavior is when I found a url of format http://​www.domain.com/a/blabla or when there is link in SMS/eMail of format domain/xyz the system should trigger my activity.
Case #1: Working fine
<activity
android:name=".MYActivity">
<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="xyz"
android:scheme="domain" />
</intent-filter>
</activity>
Case #2: Working fine
<activity
android:name=".MYActivity">
<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"
android:host="www.domain.com"
android:pathPrefix="/a"
/>
</intent-filter>
</activity>
Case #3: NOT working
<activity
android:name=".MYActivity">
<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="xyz"
android:scheme="domain" />
<data
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a"
/>
</intent-filter>
</activity>
Any suggestions/points/help is really appreciated
I placed both the deeplinks in two different intent filters and it worked!!!.
See the documentation of <data>: it states that:
All the <data> elements contained within the same <intent-filter> element contribute to the same filter.
Hence
<intent-filter>
<data
android:host="xyz"
android:scheme="domain" />
<data
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a" />
<intent-filter>
is interpreted equivalently as (not real code)
<intent-filter>
<data
android:host="xyz"
android:scheme="domain"
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a" />
<intent-filter>
which clearly has some contradictions, for example host being xyz VS www.domain.com.
From Android official documentation site :
Although it's possible to include multiple elements in the same
filter, it's important that you create separate filters when your
intention is to declare unique URLs (such as a specific combination of
scheme and host), because multiple elements in the same intent
filter are actually merged together to account for all variations of
their combined attributes.
You will have to create separate intent-filters.
Slightly off topic but relates the the OP question above with extra information that might help someone else.
If you have intent filters with deeplinks across multiple manifests and want to merge them without overriding each other you can add a unique android:label on your <intent-filter>.
Example:
main/AndroidManifest.xml
(These deeplinks are available to all app flavours, debug, prodcution etc)
<intent-filter android:label="main_deeplink1">
<data
android:host="domain.com"
android:scheme="https" />
<intent-filter>
debug/AndroidManifest.xml
(These deeplinks are available only to the debug build flavour)
<intent-filter android:label="debug_deeplink1">
<data
android:host="dev.domain.com"
android:scheme="https" />
<intent-filter>
The merged Manifest file will now contain both deeplinks without overriding each other.
Here is the tutorial I hop it helps
Tutorial link

Link from Android browser to my application not working

I want from the android browser be able to launch my application if it's installed, or launch my website in the other case.
So in order to make it work, I put :
<activity android:name=".MMLogin" android:label="MeetMe" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="http" android:host="meet-me.com" android:path="/signin" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
in the Manifest, and I created a dummy link to test; and it's not working.
I've tried with and without: BROWSABLE and DEFAULT
I've tried with meetme://datas and change the scheme; nothing worked.
I used threads on stackoverflow like :
Launch custom android application from android browser
What am I doing wrong, or is there a special thing to do to make it work ?
My application suppports from API 7.
Cheers
I used :
Intent Filter to Launch My Activity when custom URI is clicked, I think what was missing is this block :
<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" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/myapp" />
</intent-filter>

Android Intent-Filter for Multi Screen

I want to launch my application from web browser in Android using Intent-Filter based on scheme, host in the DATA tag like this.
<activity android:name=".activity.LogoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.phone.MainActivityPhone" android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<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="my" android:host="mystore" />
</intent-filter>
</activity>
<activity android:name=".activity.tablet.MainActivityTablet" android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<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="my" android:host="mystore" />
</intent-filter>
</activity>
As you see, There are two Main Activities for phone and tablet, and in LogoActivity determine which Main Activity will be opened by screen size. But the problem is when user clicks my://mystore link in web browser, there are two choices to launch that MainActivtyPhone and MainActivityTablet.
What I want is there is only one proper intent-filter works for uri my://mystore .
Any help? Thanks.
On the first run of your application, use PackageManager to disable the activity you do not want to use.
Please do not invent custom schemes. Please use HTTP URLs instead:
<data android:scheme="http" android:host="yourdomain.com" android:path="/something/or/another" />
That way, you can actually put a real Web page at http://yourdomain.com/something/or/another, so if somebody gets your link but does not have your app installed, they will see your Web page, instead of getting an error.
Also, please remove android:configChanges, or handle all configuration changes.

Categories

Resources