В следующем коде, Eclipse обнаружил ошибку:Проблема с NotificationCompact.Builder и ActionBarSherlock
The method build() is undefined for the type NotificationCompat.Builder
Все работало отлично перед добавлением ActionBarSherlock
(следующий 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
}
}
Работы спасибо !! [link] (http://stackoverflow.com/questions/12793722/error-on-add-library-project-in-eclipse) –
>> «android-support-v4.jar как в проекте ActionBarSherlock, так и в вашем основном приложении проект «. Фактически нет. Вам нужно только одно в проекте ActionBarSherlock. –
@DoctororDrive: True. Однако, если старый JAR существует в обоих проектах, замена его только одним приведет к ошибкам сборки. Либо оба проекта нуждаются в одном JAR, либо просто имеют JAR в ActionBarSherlock и не имеют JAR в основном проекте. – CommonsWare