3

I want to be notified when use click a notification. The want I am doing it now is

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>

Everything works. However, I got a warning "Exported receiver does not require permission" Which means every app can send the broadcast to my app. What permission should I add so only system notification tray is allowed to send the broadcast ?

Thanks

4

1 に答える 1

5

タグに追加android:exported="false"するだけです。<receiver ...>これにより、受信機が他のアプリからアクセスされるのを防ぎます。

于 2012-08-09T01:24:55.620 に答える