Ant 找不到 Notification.Builder 的方法构建 (android)



我按照本指南进行了通知我在SDK-17(minSdk 13)IntentService类上使用此代码。

private final int NOTIFICATION_ID=6317;
Notifiaction.Builder builder;
private void startNotification(int backupNumber) {
    builder=new Notification.Builder(this);
    builder.setContentTitle("Backup");
    builder.setContentText(getString(R.string.backup_of)+backupNumber+"app(s)");
    builder.setSmallIcon(android.R.drawable.stat_sys_download);
    Intent notificationIntent = new Intent(this, Launchalot.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    builder.setContentIntent(pendingIntent);
    mNotificationManager =(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    startForeground(NOTIFICATION_ID, builder.build());
}

我还在其他方法中使用builder.build()来更新通知

当我试图编译它时,ant找不到build()方法:

[javac] /home/edo/Dropbox/android_projects/AppShare/src/it/ptia/appshare/BackupService.java:44: error: cannot find symbol
[javac]                 mNotificationManager.notify(NOTIFICATION_ID, builder.build());
[javac]                                                          ^
[javac]   symbol:   method build()
[javac]   location: variable builder of type Builder
[javac] /home/edo/Dropbox/android_projects/AppShare/src/it/ptia/appshare/BackupService.java:65: error: cannot find symbol
[javac]             mNotificationManager.notify(NOTIFICATION_ID, builder.build());
[javac]                                                      ^
[javac]   symbol:   method build()
[javac]   location: variable builder of type Builder
[javac] /home/edo/Dropbox/android_projects/AppShare/src/it/ptia/appshare/BackupService.java:107: error: cannot find symbol
[javac]         startForeground(, builder.build());
[javac]                                      ^
[javac]   symbol:   method build()
[javac]   location: variable builder of type Builder
[javac] 3 errors

build()调用是API 16,您的最小值是13

当API低于16 时,可以使用getNotification

相关内容

  • 没有找到相关文章

最新更新