Note that there are some explanatory texts on larger screens.

plurals
  1. POsetContent is not working for NotificationCompat.Builder
    primarykey
    data
    text
    <p>I want to show a custom layout as a notification in a service.</p> <p>here is my method in the Service class:</p> <pre><code>private void fireNotification() { Log.d("Clock", "Fire!"); if (this.remoteViews == null) { Log.d("Clock", "!=null"); remoteViews = new RemoteViews(getPackageName(), R.layout.custom_notification); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher).setContent( remoteViews); // Creates an explicit intent for an Activity in your app Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder.setContentIntent(contentIntent); startForeground(1, mBuilder.build()); } } </code></pre> <p>custom_notification.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="3dp" android:background="@android:color/white" &gt; &lt;TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textColor="#000" /&gt; &lt;ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="10dp" android:background="@android:drawable/ic_menu_help" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>But the default notification shows up with my Icon! What's worng?</p> <p>EDIT: I ran my app on an emulator and it's working on Android 4 but in my phone with gingerbread it's not working!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload