Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public void remoteViewNotification(View v)
  2. {
  3. RemoteViews remoteViews = new RemoteViews(getPackageName() , R.layout.notification_view);
  4.  
  5. remoteViews.setImageViewResource(R.id.notif_image, R.drawable.android_nougat_h1);
  6. remoteViews.setTextViewText(R.id.notif_text, "Text for the Custom Ttext");
  7. NotificationCompat.Builder builder=new NotificationCompat.Builder(this).
  8. setSmallIcon(R.drawable.nougat)
  9. .setContent(remoteViews)
  10. .setAutoCancel(true);
  11.  
  12. NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  13. nm.notify(NOTIFICATION_ID,builder.build());
  14.  
  15. }
  16.  
  17. <?xml version="1.0" encoding="utf-8"?>
  18. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  19. android:layout_width="match_parent"
  20. android:layout_height="wrap_content" >
  21.  
  22. <ImageView
  23. android:id="@+id/notif_image"
  24. android:layout_width="wrap_content"
  25. android:layout_height="fill_parent"
  26. android:layout_alignParentLeft="true" />
  27.  
  28. <TextView
  29. android:id="@+id/notif_text"
  30. android:layout_width="fill_parent"
  31. android:layout_height="wrap_content"
  32. android:layout_toRightOf="@id/notif_image"
  33. android:gravity="center_vertical" />
  34.  
  35. </RelativeLayout>
  36.  
  37. android.app.RemoteServiceException: Bad notification : Couldn't expand RemoteViews for: StatusBarNotification
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement