android - 如何使用 Google Now 的 Note To Self Intent ?

标签 android gmail

我知道这不是最佳做法,但我想使用 Note To Self Intent 在后台发送电子邮件。我发现了 Keep 使用的 AUTO_SEND Intent ,但我似乎无法打开 Gmail 或 Keep - 它们没有显示在 Activity 选择器中,只有 Evermore 和 Notif 显示。

这是我目前正在尝试的:

    Intent mailClient = new Intent("com.google.android.gm.action.AUTO_SEND");
    mailClient.setClassName("com.google.android.gm", "com.google.android.gm.AutoSendActivity");
    startActivity(mailClient);

但是,我仍然遇到错误 -

04-12 15:06:28.393: W/ActivityManager(443): Permission Denial: starting Intent { act=com.google.android.gm.action.AUTO_SEND cmp=com.google.android.gm/.AutoSendActivity } from ProcessRecord{41adee50 11298:com.email_to_self/u0a10113} (pid=11298, uid=10113) requires com.google.android.gm.permission.AUTO_SEND

我通过这样做将权限添加到我的 list 中

<uses-permission android:name="com.google.android.gm.permission.AUTO_SEND"> 

但问题依然存在。有什么想法吗?

最佳答案

你不能。

此操作由此 Activity 处理,需要权限 com.google.android.gm.permission.AUTO_SEND

    <activity android:name="com.google.android.gm.AutoSendActivity"
              ...
              android:permission="com.google.android.gm.permission.AUTO_SEND">

        <intent-filter android:label="@string/app_name">
            <action android:name="com.google.android.gm.action.AUTO_SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="*/*" />
        </intent-filter>
    </activity>

此权限在 Gmail 的 list 中定义,并且仅限于 Google 的应用程序(或更准确地说,使用与 Gmail 相同的 key 签名)。

<permission android:name="com.google.android.gm.permission.AUTO_SEND"
            android:permissionGroup="android.permission-group.MESSAGES"
            android:protectionLevel="signature" android:label="@string/auto_send_perm_label"
            android:description="@string/auto_send_perm_desc"/>

关于android - 如何使用 Google Now 的 Note To Self Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15979794/

相关文章:

android - 从双摄像头 Android 智能手机获取深度

android - Endless Scroll RecyclerView 总是返回顶部

javascript - 使用 JavaScript 链接到 Gmail 消息版本的弹出窗口

google-apps-script - 是否会向 Gmail App Script API 添加一个函数来获取分配给邮件的星标类型?

php - 在 Codeigniter 中无法发送电子邮件 - fsockopen() : unable to connect to ssl://smtp. gmail.com:465(连接被拒绝)

email - 无法使用 Delphi 从 Gmail 帐户下载/检索电子邮件(SSL3_GET_RECORD :wrong version number)

javascript - 如何创建与 Gmail 联系人管理器类似的行为

android - 指南针 - 完整 360 度旋转的轨道数

android - Android Studio将无法正确执行gradle构建

java - JsonReaderException ,当从 Android 调用 AWS lambda 函数时