private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null || context == null) {
return;
}
mNotificationManager.cancel(NOTIFICATION_ID_LIVE);
String type = intent.getStringExtra(PUSH_TYPE);
if (PUSH_TYPE_LINK.equals(type)) {
//mNumLinkes = 0;
} else if (PUSH_TYPE_LIVE.equals(type)) {
//mNumLives = 0;
}
//这里可以重新计数
}
};
private void sendLiveNotification() {
Intent intent = new Intent(NOTIFICATION_CLICK_ACTION);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
String title = "Push测试";
mBuilder.setContentTitle(title);
mBuilder.setTicker(title);
mBuilder.setContentText("https://233.tv/over140");
mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
mBuilder.setSmallIcon(R.drawable.ic_action_cast);
mBuilder.setDefaults(Notification.DEFAULT_ALL);
mBuilder.setWhen(System.currentTimeMillis());
mBuilder.setContentIntent(PendingIntent.getBroadcast(this, NOTIFICATION_ID_LIVE, intent, 0));
mBuilder.setDeleteIntent(PendingIntent.getBroadcast(this, NOTIFICATION_ID_LIVE, new Intent(NOTIFICATION_DELETED_ACTION).putExtra(PUSH_TYPE, PUSH_TYPE_LIVE), 0));
mNotificationManager.notify(NOTIFICATION_ID_LIVE, mBuilder.build());
}