2013-04-12 23 views
3

我知道它不是最佳做法,但我想使用thr Note To Self在後臺發送電子郵件。我發現了Keep使用的AUTO_SEND意圖,但似乎無法打開Gmail或保留它 - 它們不會顯示在活動選擇器中,只有Evermore和Notif纔會顯示。如何從Google Now使用「注意到自我意圖」?

這裏就是我目前想:

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 

我添加了允許進入我的清單做

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

但問題依然存在。有任何想法嗎?

+3

也許你不能擁有該權限 - 它可能是'簽名'權限,要求你的應用程序使用與其他應用程序相同的簽名密鑰進行簽名。 – CommonsWare

+0

我怎樣才能確定它是或不是? – Foxh8er

回答

0

你不行。

這一行動是通過這個活動來處理,並要求允許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的清單中定義,它是一個僅限於谷歌的應用程序(或者更精確地使用相同的密鑰爲註冊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"/> 
+0

OP詢問'com.google.android.gm.action.AUTO_SEND',而不是'com.google.android.gm.permission.AUTO_SEND'。 –

+0

@TedHopp,該行爲需要此權限,至少沒有(合法的)方式,所以問題* *實際上是關於權限的。 – lapis