开始从电子邮件的Andr​​oid的意图 [英] Start Android intent from email

查看:126
本文介绍了开始从电子邮件的Andr​​oid的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不使用具有XML数据的特殊服务器的Andr​​oid设备发送信息的一个好方法。我想这个基地周围的电子邮件功能。可以说,我与一些特殊的文本/链接发送一封电子邮件,在手机上点击启动和意图时。

I need a good way of sending information TO the Android device that doesn't use a special server that has XML data. I would like to base this around email functionality. Lets say I send an email with some special text/link that when clicked starts and intent on the phone.

我不希望更换用户的当前电子邮件应用程序。可点击的链接将是最好的事情的意图://数据1:数据2或东西沿着这些路线

I don't want to replace the users current email application. A clickable link would be the best thing "intent://data1:data2" or something along these lines.

如何进行思考/解决方案。

Speculations/solutions on how to proceed.

推荐答案

是的,你可以做到这一点。您可以在您的应用程序作为处理你自己的方案(计划)注册的活动。应用程序清单将是这样的:

Yes, you can do that. You register an activity in your app as the handler for your own protocol (scheme). The application manifest will have something like:

    <activity android:name=".SchemeActivity"
        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:scheme="myownprotocol" />
        </intent-filter>
    </activity>

这个活动将不会显示或到应用程序启动器的图标,所以你可能有除了这一个普通的活动。

This activity will not be displayed or get an icon in the application launcher so you probably have an "ordinary" activity in addition to this one.

现在,任何网页可以有一个像下面的链接:

Now, any web page can have link like the following:

<a href="myownprotocol://12345">Sample link</a>

通过安装应用程序,你应该能够点击在网络浏览器这样的链接,并有我的样本中SchemeActivity显示。该活动在里面,你可以获取整个链路(并解析附加ID /数据或任何你必须有)由:

With the application installed, you should be able to click such a link in the web browser and have the SchemeActivity in my sample be shown. Inside that activity, you can fetch the whole link (and parse the additional id/data or whatever you have there) by:

String fullUrl = getIntent().getDataString();

这篇关于开始从电子邮件的Andr​​oid的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆