Android custom url works from href but not directly - android

I have defined a custom url for my Android application:
<intent-filter>
<data android:scheme="myfoo" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
When I create a web page that has
My Foo
and click on the link from the local browser, my application is launched just fine. However, if I type "myfoo://" directly in the browser, it simply takes me to Google's search listing.
Wondering if there is a setting on the default browser that I need to disable to make my custom url work. Regards.

Wondering if there is a setting on the default browser that I need to disable to make my custom url work.
Probably not. For starters, there is no single "default browser" in Android. Beyond that, browser developers are welcome to do whatever they want with URLs, including having varying behavior based upon where the URL comes from (address bar vs. link vs. JavaScript vs. ...).

Related

open android app using scheme not working

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.

How to use only my app for intent-filter URL with specific prefix?

Suppose we have an activity to resolve external URL links with a specifix pathPrefix. It's not a problem. The problem is to have a method to make those links is only resolvable with my app.
For example:
We have this 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:pathPrefix="/specific_prefix/"
android:scheme="http" />
</intent-filter>
And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?
And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?
No.
First, how URLs are interpreted is up to the app interpreting the URLs. Some Web browsers, when they encounter an http URL, will always handle it themselves, rather than seeing if a third-party app has advertised support for it.
Second, in cases where there are two or more apps that claim to support a certain operation, the user chooses which one to use. In your case, Web browsers and your app will claim to handle that URL, and the user can choose whichever of those that the user wants.
With Android 6.0's app links, you can avoid the chooser by default, so if a chooser would have appeared, the user will be taken straight to your app. The user can disable this in Settings, though.

Trouble intercepting NFC intents with my app

Here is my intent-filter code...
<activity android:name="IntentReceiver">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="http"
android:host="mytix.com"
android:pathPattern="/" />
<data
android:scheme="http"
android:host="www.mytix.com"
android:pathPattern="/" />
</intent-filter>
</activity>
What I want to do is intercept any NFC tags which have a url data type and the url is pointing to http://mytix.com (or http://www.mytix.com).
However the above code doesn't seem to work. Instead my NFC tags just open the browser and go the url in question (which is the right url! :) I've checked).
How do I intercept the intent? What I want to end up with is a tag that will take users to the mobile website if they don't have the app, but if they have the app installed it will take them straight to the app. I believe I am on the right lines, but the code above doesn't work for some reason.
I'm installing the app by building straight to the phone from Eclipse btw - does this make a difference?
Thanks
Tom
What I want to do is intercept any NFC tags which have a url data type and the url is pointing to http://mytix.com (or http://www.mytix.com).
Try NDEF_DISCOVERED, not TAG_DISCOVERED. Android will only support direct launches like this for NDEF-formatted NFC tags. If your NFC tag is using something else, you can't use the <intent-filter> AFAIK, but rather would have to parse the data out yourself.
Here is a book sample project that demonstrates writing a URL to an NDEF-formatted tag (triggered via the Share Page option in a browser app) and responding to NDEF-formatted tags with a specific URL written to them.

Launcing Applications with Custom URI on Android

I am developing an application on Android and my application needs to be launched whenever a URI like (myscheme://mydata) is clicked on an SMS or Email.
I am using following filter for my app :
<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="secture"/>
</intent-filter>
However on emails and SMS messages, my URIs with the form of myscheme://mydata show up as
regular tests and i cannot click on them to launch my application.
Thanks for help
Edit :
I found out that Linkfy class does something similar however it modifies your own text into links. What I need is modifying other applications such as Email and SMS. So is it possible to change another applications Linkfy?
So is it possible to change another applications Linkfy?
No, sorry.
Instead of myscheme://mydata, use http://mydomain/mypath. You can create an <intent-filter> for this so that you get control instead of the browser, and the resulting URLs will be friendlier to other apps. As a bonus, you can put a real Web page at that URL, so if somebody who does not have your app winds up with your URL (e.g., forwarded email), the URL will still work..

Invoke an Android App from a WebPage

Hi
Is it possible to invoke an Android App from a Web Page that i am displaying on the phone browser to the user. I know that this is possible from an another Android App using Intents. But i am not sure if this is possible from a WebPage.
Thanks in advance.
Intent filters with the BROWSABLE category will let you launch an application using a URI scheme. Inside your <activity>, add:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="myprotocol" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
and set up the action and categories how you want, and change the scheme to something relevant to your application.
Then inside your webpage, you can link to your application with
test link
Simply define a intent filter for a particular URI within your Activity:
http://developer.android.com/guide/topics/manifest/data-element.html
That way, that activity will be called when a corresponding link is clicked. By using a custom scheme you'll make sure that your app is the only one responding.
It's the same way the android market responds to market links.

Categories

Resources