2012-08-09 21 views
3

我想在使用單擊通知時收到通知。 我現在做的要的是我應該使用什麼權限給android notitications的接收者?

notification.contentIntent = PendingIntent.getBroadcast(context, 0,intent, 0); 

<receiver 
    android:name=".notificationsClickReceiver"> 
    <intent-filter > 
     <action android:name="com.example.android.notification.CLICK" /> 
    </intent-filter> 
</receiver> 

一切正常。但是,我收到警告「導出的接收器不需要 權限」這意味着每個應用都可以將廣播發送到我的應用。我應該添加什麼權限,以便只允許系統通知托盤發送廣播?

感謝

回答

5

只需添加android:exported="false"<receiver ...>標籤。這可以防止您的接收器被其他應用程序訪問。

+0

謝謝,我會試試。但系統托盤是另一個應用程序,正確嗎? – 2012-08-09 01:28:02

+0

正如在通知下拉菜單中一樣?不,這是烘烤到操作系統。 – Eric 2012-08-09 01:43:11

+0

謝謝。有效。所以操作系統可以訪問未導出的接收器。 – 2012-08-09 18:11:18

相關問題