问题
I know its not best practice, but i want to use thr Note To Self intent to send an email in the background. I found an AUTO_SEND intent that Keep uses, but I can't seem to open Gmail or Keep with it - they don't show in the activity picker, only Evermore and Notif do.
Here's what I'm currently trying:
Intent mailClient = new Intent("com.google.android.gm.action.AUTO_SEND");
mailClient.setClassName("com.google.android.gm", "com.google.android.gm.AutoSendActivity");
startActivity(mailClient);
However, I'm still getting an error -
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
I added the permission into my manifest by doing
<uses-permission android:name="com.google.android.gm.permission.AUTO_SEND">
But the problem persists. Any ideas?
回答1:
You can't.
This action is handled by this activity and requires permission 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>
This permission is defined in Gmail's manifest, and it's a limited to Google's applications (or more precisely signed with the same key as Gmail).
<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"/>
来源:https://stackoverflow.com/questions/15979794/how-can-i-use-the-note-to-self-intent-from-google-now