android Notification的使用

来源:互联网 发布:java 修改图片名字 编辑:程序博客网 时间:2024/06/15 13:29

NotificationManager nm=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

Notification notification;
notification=new Notification(R.drawable.music5,"正在播放    "+content,System.currentTimeMillis());

//创建一个启动其他activity的intent;
Intent nIntent=new Intent(context,MainActivity.class);

//PendingIntent这个类用于处理即将发生的事情。比如在通知Notification中用于跳转页面,但不是马上跳转。
PendingIntent pendingIntent=PendingIntent.getActivity(context, 0, nIntent, 0);
notification.setLatestEventInfo(context, title, content, pendingIntent);
nm.notify(0, notification);

0 0
原创粉丝点击