Jaydeep Solanki
Jaydeep Solanki

Reputation: 2945

Android Notification Custom View

I need to show a CircleImageView inside a notification, but it always crashes saying

Bad notification posted :Couldn't expand RemoteViews

I use remoteViews.setImageViewBitmap(R.id.icon, bitmap);

Here's the layout I use

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/notification_large_icon_width"
    android:layout_height="@dimen/notification_large_icon_height"
    android:id="@+id/icon_group"
    >

    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/icon"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="de.hdodenhof.circleimageview.CircleImageView"
        />

    <ImageView
        android:id="@+id/right_icon"
        android:layout_width="16dp"
        android:layout_height="16dp"/>
</FrameLayout>

Edit : If I replace CircleImageView with a regular ImageView, it works

Upvotes: 1

Views: 348

Answers (1)

dzeikei
dzeikei

Reputation: 2256

RemoteViews are not expanded in the context of your app so it doesn't have access to your custom view: CircleImageView.

For RemoteViews, you only have access to vanilla UI controls and a subset at that.

Upvotes: 2

Related Questions