I'm having trouble getting a notification with a custom layout to display. If I use the following (old) code:
notification = new Notification();
notification.icon = R.drawable.icon;
notification.tickerText = currentTickerText;
notification.when = System.currentTimeMillis();
notification.setLatestEventInfo(context, (CharSequence)currentTitle, (CharSequence)"", pendingIntent);
Everything works as expected and the notification shows up. However if I use the following (new) code:
contentView = new RemoteViews(context.getPackageName(), R.layout.service_notification);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.title, (CharSequence)currentTitle);
contentView.setTextViewText(R.id.text, (CharSequence)"");
contentView.setViewVisibility(R.id.pgStatus, View.GONE);
notification = new Notification();
notification.tickerText = currentTickerText;
notification.when = System.currentTimeMillis();
notification.contentView = contentView;
notification.contentIntent = pendingIntent;
The notification is never shown. I'm not given an error either so I'm not really sure where to look for an issue. Here is the service_notification layout code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp" >
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp" />
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:text="This is the title."
style="@style/NotificationTitle" />
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:layout_below="@id/title"
android:text="This is the status"
style="@style/NotificationText" />
<ProgressBar
android:id="@+id/pgStatus"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_toRightOf="@+id/image" />
</RelativeLayout>
Also, I'm running this on the Android 2.2 emulator if that makes a difference.
Anyone have any ideas of what could be wrong or how I could go about tracking down the issue? I'm kind of at a loss since I don't have an error message to work off of. Thanks!