{"id":428,"date":"2012-11-05T21:09:36","date_gmt":"2012-11-05T20:09:36","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=428"},"modified":"2012-11-05T21:09:36","modified_gmt":"2012-11-05T20:09:36","slug":"custom-notifications","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2012\/11\/05\/custom-notifications\/","title":{"rendered":"Custom Notifications"},"content":{"rendered":"<p>Today I ran into an interesting problem with custom Notifications. The following error kept on being thrown while I was testing with a Samsung Galaxy Ace phone:<\/p>\n<blockquote><p>&#8220;android.widget.RemoteViews$ActionException: can&#8217;t find view: &#8230;&#8221;<\/p><\/blockquote>\n<p>My custom Notification contains an ImageView and some TextViews. The image for the ImageView was being loaded from a remote server. When the image was retrieved I tried updating the Notification by modifying a clone of the original Notification I sent, calling: <\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">RemoteView.setImageViewBitmap(myViewId, bitmap)<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>\u00a0After this the app would crash. The LogCat output would then show the error above.<\/p>\n<p>Having a close look at the other Notifications displayed by the phone, it turned out that ImageViews were automatically removed.<\/p>\n<p>To solve the issue you have to make sure to always create a new Notification, that way your custom XML gets inflated and the ImageView is (again) accessible.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Today I ran into an interesting problem with custom Notifications. The following error kept on being thrown while I was testing with a Samsung Galaxy Ace phone: &#8220;android.widget.RemoteViews$ActionException: can&#8217;t find view: &#8230;&#8221; My custom Notification contains an ImageView and some &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2012\/11\/05\/custom-notifications\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[117,116],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-android","tag-custom","tag-notifications"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=428"}],"version-history":[{"count":12,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":440,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/428\/revisions\/440"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}