Unity 获取安卓通知栏信息,在通知栏新增,删除时回调。Unity 和 Java 的调用和回调还是和之前一样:交互
首先定义一个java类继承自NotificationListenerService
onNotificationPosted函数是在通知栏新增的时候回调。
onNotificationRemoved函数是在通知栏删除时回调。
public class PhoneNotifyServer extends NotificationListenerService {
private Handler mHandler;
static final String ACTION_LOCAL_BINDING = "local_binding";
public void setmHandler(Handler handler){
mHandler = handler;
}
@Override
public IBinder onBind(Intent intent) {
return ACTION_LOCAL_BINDING.equals(intent.getAction())
? new LocalBinder() : super.onBind(intent);
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
// TODO Auto-generated method stub
Android