如何在安卓系统中实现通知?

5

我正在开发一款Android版的Helpdesk应用程序。我想为未读工单(客户建议或投诉)实现通知功能。在iPhone版本的这个应用程序中,即使应用程序没有打开,未读工单的计数器也会显示在应用程序图标上。在Android上是否可能实现类似于iPhone的功能?如果可以,请帮助我实现;否则,请帮助我实现普通的Android通知功能以通知未读工单。

谢谢

2个回答

9
调用这个方法。
private void triggerNotification(String s) {
    CharSequence title = "Hello";
    CharSequence message = s;
    NotificationManager notificationManager;
    notificationManager = (NotificationManager) context
            .getSystemService("notification");
    Notification notification;
    notification = new Notification(
            com.yourPackage.R.drawable.notification, "Notifiy.. ",
            System.currentTimeMillis());
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
        null, 0);
    notification.setLatestEventInfo(context, title, message, pendingIntent);
    notificationManager.notify(1010, notification);
}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接