Android Custom URI Handler - Gmail App doesn't recognize? - android

I'm trying to open a link from my Gmail Application. If I send myapp://custom/params, Gmail only recognizes it as text. I can get the link to open my application "myapp" from a browser, though. How can I get around this?

I'd suggest that you use URIs with the content: scheme and a custom ContentProvider.
See http://developer.android.com/guide/topics/providers/content-providers.html.

I think this comes down to a problem with the way the GMail apps looks for stuff to link up as URLs in the body of a text formatted message. I believe you have two options:
Send the email message as HTML instead of plain text and explicitly href= link to your custom scheme.
Instead of hooking to a custom scheme, setup your app to handle protocol http with the host and path set to something unique. As long as you include the exact path the intent filter shouldn't get in the way of normal browsing to your website.
I haven't tried either of those. #2 I'm pretty definite will work, however #1 might be a bit cleaner depending on your app.

Related

Is it possible to get URL of the page when sharing the selected text from the Chrome or other web-browser app?

In my app i handle Intent.ACTION_SEND intent sent from other apps.
One of such senders can be the Chrome app.
I can simply send the URL of the current page or the selected text from the Chrome app to my app via built-in 'Share to ...' functionality inside the Chrome. In both cases in my app I can access the shared text via Intent.EXTRA_TEXT.
However for the case when selected text is shared additionally to the text itself I would like to receive the URL of the page to which this text belong.
I've blindly tried several other Intent.EXTRA_xxx fields but without any luck.
Does anyone know is it possible at all? Is it more-or-less universal or app-specific?
In case if it is not possible to receive this info from the intent, are there any other ways to achieve the similar goal? Maybe somehow ask the chrome-app directly what is/was the current page? Will be glad to any ideas...

Is it possible to send an SMS with hyperlink and anchor text (hidden URL) on Android device?

I know that the Android Message app can parse URLs that starts with "www" and "http://", making them hyperlinks. But is it possible to send a hyperlink, where only the anchor text is displayed and the URL is hidden?
Thanks
Basically, no, you can't.
SMS is a specific standard that contains just text. So when you send something that looks like a URL, the Android (and iOS/Windows/whatever) messaging apps can detect it using a RegEx or similar and make it a link. But you can't do anything like an <a href=""> tag as you would with HTML. You might be able to use MMS to achieve this, but I'm not 100% on that.
Good luck!

action_send mime type for links

When someone longpresses a link and chooses share link and select my app it grabs it and does what it does.. but this also works with other sharable text items. I would like to only accept links. Currently i have the mime type as text/plain. Is there a mime type for links?
No, sorry. At least for the standard Android browser, it uses text/plain. You are welcome to examine the value that is sent to you, see if it looks like a URL via a regular expression, and pop up an error indicating that you only send links.
In theory, you could even then turn around and execute startActivity() for the same Intent, to allow the user to choose something else to try sharing with. I have not tried this, though, so there could be some hiccups here that I am not aware of.

Intent Filter on Android

I am reading the intent filter of the android, and having a few question need to ask.
Do they match the filter within the same application or all of the applications?
The scheme within the data tag, I have looked on the documentation on the android sdk website but no idea what it mean. It say scheme://host:port/path or pathPrefix or pathPattern
What is the host port and path .... What does the path relate to?
1) Depends on the type of intent that was requested. See implicit vs explicit intents in the "Intent resolution" section of the docs:
http://developer.android.com/guide/topics/intents/intents-filters.html
If you name the component exactly then you know which activity will launch. Other intents name a generic action and can be matched by multiple activities. The user gets a menu asking which app they want to use to complete the action normally. For instance download the Firefox app from the Marketplace and click on a link in an email, you'll get a prompt asking if you want to use the Browser or Firefox to open the URL.
2) That's for intercepting a custom URL scheme or overlaying HTTP requests. Sounds like that not something you're interested in doing, you can safely ignore it unless you need to use it. If you do want more info about it there's a question with some good answers already:
Launch custom android application from android browser
1) see #mikerowehl answer
2) data is referenced through Uniform Resource Indentifiers (URI's). In Android, scheme could be http, tel, file, content (don't know about others) and by specifying a certain scheme in a filter you're saying that your component can handle data provided that way.
host+port=authority. In case of a data whose scheme is http, host will of course be something like stackoverflow.com, port will probably be left unspecified (if you're accessing a proxy it could be 8080). In case of a content provider, the authority is by convention "the fully-qualified class name of the content provider (made lowercase)", without a port.
This should be the general idea. Documentation in this field is pretty scattered but you should be able to find information on a particular task (say opening email attachments) when you'll need.

Adding links to an email message

I was wondering if it is possible to hook into the gmail and email
applications and check to see if it contains text that matches a
regular expression, and if it does, make that text into a link with a
URI that would open my application. What i am thinking of is similar
to how the gmail application can detect a web address or phone number
and make it a link. Is something like this possible?
The Gmail app is closed source and you only have the hooks they give you. AFAIK regular-expression-to-hyperlink-conversion isn't one of them:
Extending Android's Default Gmail/Email Applications
Depending on what you're doing, you might be able to send mail through some kind of gateway which does this work on the message prior to delivery. So rather than emailing johndoe#gmail.com people could write to johndoe#example.com, and the work of translating phrases into URIs could be done at example.com then forwarded to gmail.com with links in place...
But people are link-savvy these days. You can make links plenty readable, for instance look at http://en.wikipedia.org/wiki/URL ...fairly obvious, no magic required and I can enter that even without Google's help.

Categories

Resources