public void onClick(View v) {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 1,
notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationManager nm = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Resources res = this.getResources();
Notification.Builder builder = new Notification.Builder(this);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(
BitmapFactory.decodeResource(res,
R.drawable.ic_launcher)).setTicker("helllo")
.setWhen(System.currentTimeMillis()).setAutoCancel(true)
.setContentTitle("Messge").setContentText("Messge22");
Notification n = builder.build();
nm.notify(5, n);
}
我想利用这个代码发送Notifcation在按钮的点击,但存在代码来显示它错误调用错误需要API级别11(目前最小为8): android.app.Notification.Builder#setContentIntent我已成立项目API级别19,请帮我哪里做错了,请给我建议的解决方案的目标=机器人-19项目根据企业的性质,而我不得不代码:如何显示Notificaion在Android API级别19
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
集安卓的minSdkVersion =“11”中的清单文件 – santalu 2014-10-10 07:01:23