Handling Status Bar notification

Posted by MAkS on Stack Overflow See other posts from Stack Overflow or by MAkS
Published on 2010-03-08T14:56:03Z Indexed on 2010/03/08 15:21 UTC
Read the original article Hit count: 323

Filed under:

in my app a background service starts and from that service i want to set Status bar notification, that the service has Started following is the code :

    Context context = getApplicationContext();
    String ns = Context.NOTIFICATION_SERVICE;
    int icon = R.drawable.icon;
    CharSequence tickerText = "Hello";
    long when = System.currentTimeMillis();
    Notification notification = new Notification(icon, tickerText, when);
    CharSequence contentTitle = "My notification";
    CharSequence contentText = "Hello World!";
    Intent notificationIntent = new Intent(MyService.this, MyClass.class);
    notificationIntent.setFlags(  Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent contentIntent = PendingIntent.getActivity(this,0,notificationIntent,0);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
   NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
   mNotificationManager.notify(1, notification);

Notification is displayed in Status bar But whin i click on that MyClass.class is not fired.And in log cat it shows "Input Manager Service Window already focused ignoring focuson ...."

so plz provide solution.

thanks in advance

© Stack Overflow or respective owner

Related posts about android