Android的状态栏通知 [英] Android-Status bar Notification

查看:96
本文介绍了Android的状态栏通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我想现在如何在主页状态通知栏。谁能帮我用C $ CS约$。先谢谢了。

解决方案

  notificationManager =(NotificationManager)_context.getSystemService(Context.NOTIFICATION_SERVICE);
时长= System.currentTimeMillis的();
INT _icon = R.drawable.icon;

意向意图=新的意图(_context,your_file.class);

PendingIntent contentIntent = PendingIntent.getActivity(_context,0,意向,0);

通知通知=新的通知(_icon,_text时);
notification.setLatestEventInfo(_context,_title,_contentText,contentIntent);
INT NOTIFICATION_ID = 10;
notificationManager.notify(NOTIFICATION_ID,通知);
 

要取消的通知

  notificationManager.cancel(NOTIFICATION_ID);
 

I am new to android. I want to now how to create a status notification bar in the home page. Can anyone help me with some codes. Thanks in advance.

解决方案

notificationManager = (NotificationManager)_context.getSystemService(Context.NOTIFICATION_SERVICE);
long when = System.currentTimeMillis();
int _icon=R.drawable.icon;

Intent intent = new Intent(_context, your_file.class);

PendingIntent contentIntent = PendingIntent.getActivity(_context, 0, intent, 0);

Notification notification = new Notification(_icon,_text,when);
notification.setLatestEventInfo(_context, _title, _contentText, contentIntent);
int NOTIFICATION_ID = 10;
notificationManager.notify(NOTIFICATION_ID, notification);

To cancel notification

notificationManager.cancel(NOTIFICATION_ID);

这篇关于Android的状态栏通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆