I'm trying to build a notification upon Android 2.3.3. I need a custom layout and I can't use Notification Builder. This is the layout of the notification:
R.layout.notification_upload
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_notification_upload"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageview_icon"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher"
android:contentDescription="@string/icon" >
</ImageView>
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true" >
</ProgressBar>
</RelativeLayout>
This is the code for the notification:
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(context, HomeActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.notification_upload);
Notification notification = new Notification();
notification.when = 0;
notification.icon = R.drawable.ic_launcher;
notification.contentIntent = pendingIntent;
notification.contentView = contentView;
notificationManager.notify(0, notification);
I'm getting: Bad notification posted from package: couldn't expand RemoteViews for... Where am I getting wrong? Can I use ImageView inside notification?