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