android中的通知
16lz
2022-01-12
因为很长时间没用过通知了,客户端的通知也一直不是自己在负责的,所以想着复习一下。真正写了之后才发现android的通知已经有了很大的变化。
//获取通知管理器 notificationManager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); RemoteViews remoteViews=new RemoteViews(getPackageName(),R.layout.notification_view);//通知的正文布局 //延时意图,点击通知后的跳转 PendingIntent pendingIntent=PendingIntent.getActivity(this,2,new Intent(this,SecondActivity.class),PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher).setContentTitle("notification title") .setContentText("text") .setContent(remoteViews).setContentIntent(pendingIntent); notificationManager.notify(1, mBuilder.build());由于时间关系,先写这么多,后期有时间再补充。。。
详细参考:android通知1 全面讲解通知
更多相关文章
- android中如何隐藏应用程序标题栏和通知栏
- Android(安卓)日期和时间选择控件的开发
- Android自带Music播放器更新播放时间和进度条的方法
- Android消息通知(notification)和PendingIntent传值
- Best Android(安卓)Remote Desktop Apps?
- Android消息通知(notification)和PendingIntent传值
- cordova的android notify消息通知插件
- Android(Java):Android的状态栏通知(Notification)
- Android(安卓)加快编译时间