【发布时间】:2018-09-20 19:28:56
【问题描述】:
为了阅读android通知,我们需要创建一个扩展NotificationListenerService类的自定义类。但是我不明白这个方法里面的作用是什么?
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i(TAG,"********** onNotificationPosted");
Log.i(TAG,"ID :" + sbn.getId() + "t" + sbn.getNotification().tickerText + "t" + sbn.getPackageName());
Intent i = new Intent("com.example.readandroidnotification.NOTIFICATION_LISTENER_EXAMPLE");
i.putExtra("notification_event","onNotificationPosted :" + sbn.getPackageName() + "n");
sendBroadcast(i);
}
谁能解释这段代码的工作原理?
【问题讨论】:
标签: android android-notifications notification-listener