bharathi
bharathi

Reputation: 6271

Android-Status bar Notification

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.

Upvotes: 2

Views: 2597

Answers (2)

viv
viv

Reputation: 6177

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

Upvotes: 5

Amer Sohail
Amer Sohail

Reputation: 61

Look at it: Android Status Bar

Upvotes: 1

Related Questions