简体   繁体   中英

Launch activity from email link

What I am desperately trying to achieve is to launch my app when the user clicks on a link sent by email. The user will open his/her android gmail app (as of today version is 2.3.6 in my 2.3.3 Android phone) and instructed to follow the link so that my app can be launched and start working.

I have already read tons of documentation from the developer corner in the android site and also similar questions here in SO and have of course used google-fu, but no working answer has been given to date, not even from the Android crew itself which in fact is using SO as the de facto Q/A place.

I have tried putting in the manifest file this config:

    <activity android:name=".MyApp" > 
        <intent-filter> 
             <action android:name="com.my.actions.MY_CUSTOM_ACTION" /> 
             <category android:name="android.intent.category.DEFAULT" /> 
             <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter> 
    </activity></code>

It didn't work so i also tried to write my custom scheme even though hackbod says not to , but also that didn't work at all. Another option is to have a custom website so that a "data" tag could be used in the intent-filter specifying an http scheme and the host, but this is a show stopper for a lot of people that don't have a website.

Maybe I am missing something. Is is possible at all what I am doing? ie: Is is possible to launch an activity from a link written in an email from the gmail android app?. If it is, what structure/syntax such link has to follow?. I can't believe this can be so strange. It's used in BB and iOS without any problems.

Any help appreciated. Thanks in advance.

The user will open his/her android gmail app

You have no way of knowing that. The user might be using any number of email clients. They will not all have the same behavior, though most hopefully handle http: links fairly consistently.

but no working answer has been given to date

Yes, they have. I have done so personally.

Another option is to have a custom website so that a "data" tag could be used in the intent-filter specifying an http scheme and the host, but this is a show stopper for a lot of people that don't have a website.

Setting up a Web site takes a few minutes and a few dollars. Moreover, they need to do that anyway, to have a site for marketing the app in question. If they cannot afford this, they cannot afford the $25 to list the app on the Play Store or the similar fees for other marketplaces. And, if they are writing this app for a business, that business should already have a Web site. And, at the end of the day, the URL does not need to actually resolve to anything real on the Internet, if the developer does not mind the user getting a 404 if the email is clicked in places where there is no app.

Hence, if this is a "show-stopper", so is breathing.

Is is possible at all what I am doing?

Yes.

If it is, what structure/syntax such link has to follow?

http://www.this-so-does-not-exist.com/something works nicely to launch this sample app , via the following <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" android:host="www.this-so-does-not-exist.com" android:path="/something" />
  </intent-filter>

You will notice that this URL leads to a 404, demonstrating that you do not actually need to spend any money to get this technique to work. Also note that this technique has been written up in a few places here on StackOverflow and many places elsewhere.

However, the intent: scheme does not seem to be picked up by Gmail, even when used in an HTML email message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM