I am trying to implement an intent filter but for some reason (unknown to me) can succeed.
I declared activity in the following way:
<activity
android:name="com.example.StartActivity"
android:label="#string/start_activity_title"
android:windowSoftInputMode="adjustPan"
android:exported="true">
<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="terms-signed.com"
android:pathPrefix="/?"/>
</intent-filter>
</activity>
The browser tries to open URIs like myapp://terms-signed.com/?documentKey=SOME-HEX
No matter if I put such URI in the browser address field or if I tap on a similar link in a HTML page, nothing happens.
There is no chooser shown, my app does not become foremost, Android does not launch my app if it's not running. Nothing. Only browser shows page with message that the webpage at the address might be temporarily down etc.
I am using Android 4.2.1 / Galaxy Nexus.
What can be done to make this work?
Remove the ? from the pathPrefix, it is not a part of the path. Maybe you can even remove the whole pathPrefix parameter, as you don't have any path after the host.
Edit2: As it can be seen in the comments, additionally removing the hyphen and the .com from the host declaration resolved the issue. My best guess would be that the browser will treat the URI as a web URI because of the .com, regardless if it is using a custom scheme.
Related
I'm trying to make one app link to open our app instead the browser.
The app links Assistant tells me that the pattern works fine but when I try it on the emulator or physical device it doesn't work :(
Filter:
<activity android:name=".activities.AppLinksActivity">
<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="http"
android:host="www.emagister.com"
android:pathPattern="/.*-cursos-.*.htm"
/>
</intent-filter>
</activity>
Url to match: http://www.emagister.com/curso-avanzado-lenguaje-programacion-javascript-cursos-2863146.htm
Assistant message:
Assistant image pic
But when I open it on the device or click run test i doesn't work and opens the browser.
If I put android:pathPattern="/juridico-master-compliance-officer-controller-juridico-empresarial-cursos-3299291.htm" in the manifest instead the above pathpattern everything works perfect.
What I'm doing wrong?
Thanks in advance!!
Your pathPattern regex seems unnecessarily complex; I don't believe it's documented which regex parser is used here, but I wouldn't be surprised if it's somehow choking on this.
Try simplifying as much as possible and then add elements back (but as few as possible). I suspect pathPattern='.*cursos.*' would still get you the same thing.
I have an android app with manifest file like this:
<intent-filter>
<data android:host="myurl.com"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
which means my app can open urls match whit a given filter.
In most android devices this works fine, but in some devices like samsung A5 2016 when user clicks on links like this android doesn't show other browsers and automatically open the link with my app.
I use normal Intent to open links in my app. But I can't fix the problem.
Can anyone help me?
It seems because I added intent-filter to my manifest file it blocks other apps to run this url.
I removed intent-filter from manifest file and it worked. But I wanna my app to be able to open urls which I mentioned in manifest file.
I feel stupid as I have found three different questions which seem to be the same as mine, but I can't get it to work. I tried "Open Android app using intent-filter not working", "Open Android app from URL using intent-filter not working", and "Open Android app from URL using intent-filter not working for 4.1 version 2". My app captures activity on my mobile web site using a WebView, but I know a lot of my users use Google to launch their browser. I would like instead for it to launch my app. In addition, it would be nice when a user types the address of my site into a browser, they would get a selection dialog to give them the option of using my app for my web site. My Manifest has the following:
<activity android:name=".MainActivity">
<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:host="www.tennisrecruiting.net" />
<!--<data android:pathPattern="/.*" />-->
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have tried it with and without the commented out line, and with the pattern ".*" but none of them work. That is, if I type "tennisrecruiting" into a google search, and click on a choice that takes me to "http://tennisrecruiting.net", the phone goes directly to my Chrome browser without asking to use my app. Similarly, if I am in my chrome browser and type "http://tennisrecruiting.net" as the target URL, chrome just opens my site without launching my app or asking the user for a choice.
What am I doing wrong - other questioners seem to get it to work but I have tried all of their solutions and they don't work for me. I have a Galaxy G6 on Verizon with Android version 6.0.1, Kernel version 3.10.61
I figured out my own problem but thought it would be good to post the answer in case someone else has the same problem. The problem was that I only had one browser, Chrome, on my device and it was, of course, registered for the http scheme. Since it was the only one, my device treated it as the preferred app for all http schemes. My scheme was more selective by designating a host. The solution was to download another browser so that none were user preferred, then when Google was navigating to http://tennisrecruiting.net, my app was listed for selection. I still don't get a transfer or selection when my mobile website is entered into Chrome but that is not surprising.
I defined the following intent filter in my application in order to make it respond to url links.
<intent-filter>
<data android:scheme="http"/>
<data android:scheme="https"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
Now when I click a link in an external app (from example a link sent by sms) it opens my app in an embedded way in the current application. Meaning that if I go to background I see my app inside the sms application.
I want the link to make my application to be opened separately. This is the correct behaviour, and happens for example when choosing chrome/ android native browser as the app to open the link.
Is there a way to change that for my app as well?
You have to set the launchMode of your activity to singleTask or singleInstance. This will force the system to open a new task for your app instead of opening it in the same task as the sms-app or whatever.
It should look somehow like this:
<activity android:name="yourActivity"
android:launchMode="singleTask">
</activity>
For more information, see the documentation: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
I have an Activity that is successfully invoked for the MIME type in which I'm interested. The content being sent from the server is an XML document created as the result of a POST. I've tried to process the result two different ways and I'm not having luck with either:
android:mimeType="application/customapp" Doing this, my activity runs, but the URI I get from Intent.getData() is the URL used for the post. A call to getContentResolver().openInputStream() results in java.io.FileNotFoundException: No content provider: http://.... Obviously, just hitting that URL won't work as I don't have the posted data.
android:pathPattern=".*\custom.app" The last segment of the URL is custom.app, so I tried using that with a path pattern. This way, the browser attempts to download the document and one of two things happens: The stock browser attempts to download "untitled" and fails. Opera downloads the document, naming it as hoped, and will offer to open the file, which works, but Opera Mini does nothing but download the file.
Here is the relevant section of my manifest with the scheme in:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".CustomappActivity" android:label="#string/app_name">
<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:mimeType="application/customapp" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
</application>
I'd like to use the first option, but could put up with the second even if it required Opera, but only if it worked consistently across both versions of Opera. I just can't see a way to get an input stream for the result being sent from the server.
I'll answer my own question. Apparently, I'm screwed. There is a known issue with the stock browser and the way it interacts with the download manager. At this time, it cannot retrieve documents that are sent as the result of an HTTP POST. The bug is detailed here