Android状态栏通知

时间:2010-10-18 08:04:39

标签: android

我是android新手。我现在想要如何在主页中创建状态通知栏。任何人都可以帮我一些代码。提前谢谢。

2 个答案:

答案 0 :(得分:5)

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);

取消通知

notificationManager.cancel(NOTIFICATION_ID);

答案 1 :(得分:1)

看看它: Android Status Bar