2012-06-03 57 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; 
}