Android消息推送接收后,通知栏的显示

原文地址为: Android消息推送接收后,通知栏的显示

消息推送接收到后,显示通知栏

    public static void showNotifictionIcon(Context context) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Intent intent = new Intent(context, XXXActivity.class);//将要跳转的界面
//Intent intent = new Intent();//只显示通知,无页面跳转
builder.setAutoCancel(true);//点击后消失
builder.setSmallIcon(R.drawable.app_icon);//设置通知栏消息标题的头像
builder.setDefaults(NotificationCompat.DEFAULT_SOUND);//设置通知铃声
builder.setTicker("状态栏显示的文字");
builder.setContentTitle("标题");
builder.setContentText("通知内容");
//利用PendingIntent来包装我们的intent对象,使其延迟跳转
PendingIntent intentPend = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(intentPend);
NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
manager.notify(0, builder.build());
}

转载请注明本文地址: Android消息推送接收后,通知栏的显示

你可能感兴趣的:(Android消息推送接收后,通知栏的显示)