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

时间:2013-07-15 10:14:57

标签: android ant android-notifications

我跟着this guide发了通知 我在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

1 个答案:

答案 0 :(得分:0)

The build() call is API 16 and your min is 13

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