如何在Android中进行通知? [英] How to do notification in android?

查看:72
本文介绍了如何在Android中进行通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在在android上创建一个技术支持应用程序.我想对未读票证(客户建议或投诉)实施通知.在此应用程序的iPhone版本中,即使该应用程序未在该应用程序图标本身上打开未读票的计数器,在Android中还是有可能的.如果是这样,请帮助我实现类似iPhone的功能,否则请帮助我实现未读票证的常规android通知.

谢谢

解决方案

调用此方法

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);
}

I am doing a helpdesk application on android. I want to implement a notification for unread tickets(customer suggestions or complaints). In iPhone version of this app, even if the app is not open a counter for unread tickets on the app icon itself, is it possible in android. If it so please help me to implement like iPhone otherwise help me to implement normal android notification for unread tickets.

Thanks

解决方案

call this method

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);
}

这篇关于如何在Android中进行通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆