我嘗試顯示自定義推送通知與下面的代碼:自定義推送通知不顯示
RemoteViews contentView = new RemoteViews(app.context.getPackageName(), R.layout.multiline_notification_layout);
contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
contentView.setTextViewText(R.id.text, text);
contentView.setTextViewText(R.id.title, title);
notification = new NotificationCompat.Builder(app.context)
.setSmallIcon(R.drawable.ic_launcher)
.setWhen(0)
.setContent(contentView)
.setContentIntent(contentIntent)
.setAutoCancel(true)
.build();
}
mNotificationManager.notify(NOTIFICATION_ID, notification);
NOTIFICATION_ID++;
,我瞭解當推收到的圖標。 如果我將刪除.setSmallIcon(R.drawable.ic_launcher)
我不會顯示。
佈局代碼:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="@+id/title"
android:layout_toRightOf="@+id/image"
android:layout_margin="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Text"
android:id="@+id/text"
android:layout_below="@+id/title"
android:layout_toRightOf="@+id/image"
android:layout_margin="5dp"
android:inputType="textMultiLine" />
確切地說,這不是我所需要的。用「簡單」推送通知我有問題。但是,我有自定義佈局的推送通知問題。 –