2013-07-15 48 views
1

我跟着this guide發出通知 我在SDK-17(minSdk 13)IntentService類上使用此代碼。Ant無法找到Notification.Builder的方法構建(android)

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(),以更新通知

當我嘗試編譯螞蟻無法找到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 
+0

無法ÿ你用NotificationCompat做到了嗎? –

回答

相關問題