I'm trying to use a custom layout for my Notification
but without success so far. My layout file is the following :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="New Text"
android:id="@+id/textView7"
android:layout_gravity="center_horizontal"/>
`
and the code to display it is :
c=new Notification.Builder(this);
v=new RemoteViews(myPackage,R.layout.myLayoutFile);
c.setContent(v);
((NotificationManager)getSystemService(NOTIFICATION_SERVICE).notify(2,c.build());
but no Notification
appears in the status bar. If I use a standard layout (i.e I use setSmallIcon
, setContentTitle
and setContext
to define mandatory elements), the Notification
is correctly displayed.
What is wrong with my code?
This question has been marked as "duplicate". This is only partially true : nothing in the question mentionned as duplicate explains that my problem was not defining the small icon for the notification. Of Course, answers to the "original" question helped me discover I was missing the small icon definition for my Notification
but it was not straightforward, and this question had to be presented to me while I was digging in the "stack" which, as far as I remember, didn't happen...