2012-06-03 118 views
0

如何将我的应用程序的徽标放置在通知栏中? 我见过很多应用程序。状态通知栏上的徽标Android

例如,这一个在左边:

screenshot

感谢。

+0

看到这使后:: http://stackoverflow.com/questions/3712758/controlling-the-android-status-bar-icon – Eight

+0

@ abhinav8,谢谢,这个问题似乎是相似的,但没有接受的答案,也没有提示代码示例。但也会找那个帖子。 – azizbekian

+0

我将你的问题标题复制到谷歌,我得到的第一个打击是[官方文档](http://developer.android.com/guide/topics/ui/notifiers/notifications.html)。它用示例解释了与通知有关的所有信息,包括这些。所以下次再搜索一下,在这种情况下会节省半个小时。 – 2012-06-03 08:34:20

回答

1

在这里,他们是

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


private void notification(String message){ 

    int icon = R.drawable.ic_launcher; 
    CharSequence ticket = message; 
    long when = System.currentTimeMillis(); 
    Notification notification = new Notification(icon, ticket, when); 
    notification.flags |= Notification.FLAG_AUTO_CANCEL; 
    CharSequence contentTitle = "Buzz Off"; 
    CharSequence contentText = message; 
    Intent intent = new Intent(this, HomeScreen.class); 
    PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0); 
    notification.setLatestEventInfo(this, contentTitle, contentText, activity); 
    nm.notify(layout, notification); 
    buzzOff = true; 
}