Nel codice seguente, Eclipse trovato un errore:Problema con NotificationCompact.Builder e ActionBarSherlock
The method build() is undefined for the type NotificationCompat.Builder
Tutto ha funzionato bene prima di aggiungere il ActionBarSherlock
(segue this tutorial).
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
}
}
Opere grazie !! [collegamento] (http://stackoverflow.com/questions/12793722/error-on-add-library-project-in-eclipse) –
>> "android-support-v4.jar sia nel progetto ActionBarSherlock che nella tua applicazione principale progetto." Attualmente no. Ne hai bisogno solo uno nel progetto ActionBarSherlock. –
@DoctororDrive: vero. Tuttavia, se il vecchio JAR esiste in entrambi i progetti, la sua sostituzione in uno solo causerà errori di compilazione. Entrambi i progetti necessitano dello stesso JAR o semplicemente del JAR in ActionBarSherlock e non hanno il JAR nel progetto principale. – CommonsWare