Android 实现应用通知效果

    public void send(View view){
         //实例化通知
        NotificationCompat.Builder builder=new NotificationCompat.Builder(this);
        builder.setContentTitle("提示");
        builder.setContentText("中奖啦!请先汇款到XXX账号激活");
        builder.setSmallIcon(android.R.drawable.star_on);//设置通知的图片
        builder.setDefaults(NotificationCompat.DEFAULT_ALL);
        builder.setAutoCancel(true);
//      builder.setContentIntent()
//        builder.setCustomContentView()
        Notification notification=builder.build();

        //发送通知
        notificationManager.notify(0x101,notification);
    }

上述代码就可以实现啦

猜你喜欢

转载自blog.csdn.net/zhangkaidsy/article/details/75943262