android – 使用NotificationCompact.Builder和ActionBarSherlock发行

android – 使用NotificationCompact.Builder和ActionBarSherlock发行,第1张

概述在下面的代码中, Eclipse发现了一个错误: The method build() is undefined for the type NotificationCompat.Builder 添加ActionBarSherlock之前,一切顺利. import android.app.Notification;import android.app.NotificationManager;im 在下面的代码中,Eclipse发现了一个错误:
The method build() is undefined for the type NotificationCompat.Builder

添加ActionBarSherlock之前,一切顺利.

import androID.app.Notification;import androID.app.notificationmanager;import androID.app.PendingIntent;import androID.app.TaskStackBuilder;import androID.content.broadcastReceiver;import androID.content.Context;import androID.content.Intent;import androID.support.v4.app.NotificationCompat;public class NotificationActivity extends broadcastReceiver {    notificationmanager nm;    @OverrIDe    public voID onReceive(Context context,Intent intent) {        nm = (notificationmanager) context                .getSystemService(Context.NOTIFICATION_SERVICE);        int notifyID = 1;        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(                context)                .setSmallicon(R.drawable.zcicon)                .setautoCancel(true)                .setDefaults(                        Notification.DEFAulT_SOUND                                | Notification.DEFAulT_liGHTS)                .setTicker("myTitle").setContentTitle("mycontent")                .setContentText("text,text");        Intent resultIntent = new Intent(context,CalcareReader.class);        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);        // Adds the back stack for the Intent (but not the Intent itself)        stackBuilder.addParentStack(MyActivity.class);        // Adds the Intent that starts the Activity to the top of the stack        stackBuilder.addNextIntent(resultIntent);        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);        mBuilder.setContentIntent(resultPendingIntent);        nm.notify(notifyID,mBuilder.build()); // error here    }}
解决方法 build()已添加到新版本的AndroID支持包中.根据您获取和设置ActionbarSherlock的方式,您可能会使用旧版AndroID支持包.确保您在SDK Manager中下载了最新版本,然后在ActionbarSherlock项目和主应用程序项目中使用该androID-support-v4.jar. 总结

以上是内存溢出为你收集整理的android – 使用NotificationCompact.Builder和ActionBarSherlock发行全部内容,希望文章能够帮你解决android – 使用NotificationCompact.Builder和ActionBarSherlock发行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1132126.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存