setGroup()是否为类型NotificationCompat.Builder定义? [英] setGroup() is undefined for the type NotificationCompat.Builder?

查看:87
本文介绍了setGroup()是否为类型NotificationCompat.Builder定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的消息应用程序(即Web应用程序)中收到stck类型的通知.我的通知正在运行..但是每次收到新通知时,以前的通知就会消失,而新通知会消失.当我用谷歌搜索时,我发现可以使用setGroup.但是当我用它的时候就表明了

I like to have a stck type notification for my message app which is a webapp. My notifications are working..But each time a new notification comes the previous notification dissapears and new one comes. When i googled i found that setGroup can be used. But whe i used it it is showing that

setGroup()对于NotificationCompat.Builder类型是未定义的.

setGroup() is undefined for the type NotificationCompat.Builder.

我的通知功能是:

    public void CreateNotification(String msg)
    {
        Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),
                R.drawable.icon);

    Intent notificationIntent = new Intent(AndroidMobileAppSampleActivity.this, AndroidMobileAppSampleActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(AndroidMobileAppSampleActivity.this, 0, notificationIntent, 0);
     NotificationManager notificationManager = (NotificationManager) AndroidMobileAppSampleActivity.this
                .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification noti = new NotificationCompat.Builder(AndroidMobileAppSampleActivity.this)
                        .setSmallIcon(R.drawable.icon)
                        .setTicker("New message from "+msg)

                        .setWhen(System.currentTimeMillis())
                        .setContentTitle("Mybuzzin")

                        .setContentText(msg)
                        .setContentIntent(contentIntent)
                        //At most three action buttons can be added
                        .setAutoCancel(true).build();    
     noti.defaults |= Notification.DEFAULT_SOUND;
     noti.defaults |= Notification.DEFAULT_VIBRATE;
     noti.flags |=Notification.FLAG_SHOW_LIGHTS| Notification.FLAG_AUTO_CANCEL;    
     notificationManager.notify(notifyID, noti);
}

推荐答案

我遇到了同样的问题,但是几个小时后,我又解决了许多其他问题.我假设您也在使用Eclipse,否则解决方案将有所不同.

I had the same problem, but after several hours and many other problems i solved it. I assume you are using also Eclipse, otherwise the solution will be different.

您必须在SDK管理器中更新android.尤其是Android SDK Build-Tools,之后您必须安装API20.现在,您必须按照以下说明更新ADT: https://stackoverflow.com/a/24437737/2061089 现在更新后,请不要担心.在安装更新之前,您必须删除要更新的所有组件.

You have to update your android in the SDK manager. Especially the Android SDK Build-Tools and afterwards you have to install API20. Now you have to update your ADT as described here: https://stackoverflow.com/a/24437737/2061089 Don't worry after the update its working now. Before you can install the update, you have to remove all components that you want to update.

重新启动eclipse之后,您只需更新项目中所有支持(v4,v7和v13)的软件包.取决于您使用的是什么.

After restarting eclipse you only have to update ALL your support(v4,v7 and v13) packages in your projects. Depending on what you are using.

完成.现在一切都是最新的,一切正在正常进行.

Finished. Now everything is up to date and eveything is working.

希望有帮助!

这篇关于setGroup()是否为类型NotificationCompat.Builder定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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