Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void remoteViewNotification(View v)
- {
- RemoteViews remoteViews = new RemoteViews(getPackageName() , R.layout.notification_view);
- remoteViews.setImageViewResource(R.id.notif_image, R.drawable.android_nougat_h1);
- remoteViews.setTextViewText(R.id.notif_text, "Text for the Custom Ttext");
- NotificationCompat.Builder builder=new NotificationCompat.Builder(this).
- setSmallIcon(R.drawable.nougat)
- .setContent(remoteViews)
- .setAutoCancel(true);
- NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
- nm.notify(NOTIFICATION_ID,builder.build());
- }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
- <ImageView
- android:id="@+id/notif_image"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_alignParentLeft="true" />
- <TextView
- android:id="@+id/notif_text"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_toRightOf="@id/notif_image"
- android:gravity="center_vertical" />
- </RelativeLayout>
- android.app.RemoteServiceException: Bad notification : Couldn't expand RemoteViews for: StatusBarNotification
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement