状态通知栏Android上的徽标

时间:2012-06-03 08:04:31

标签: android image notifications status graphical-logo

如何将我的应用的徽标放在通知栏中? 我见过很多应用程序都在这样做。

例如左边的这个:

screenshot

感谢。

1 个答案:

答案 0 :(得分: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;
}