David Barishev David Barishev - 1 year ago 189
Android Question

Creating custom notification with xamarin.android

I have been trying to make a fully custom notification with Xamarin.android.

My project targets min API of 14, so expended notification are supported. I'm trying to achieve the same look for all API's so i'm using


I have found out that you can use setCustomContentView to set a custom View that will change the layout of the notification complitly, which is what i aim for.

Here is the code that i have tried to run:

RemoteViews widgetLayout = new RemoteViews(PackageName,Resource.Layout.SingleNotificationLayout);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this)

notificationManager.Notify(notificationId, builder.Build());

is a layout file for the notification.Im running this code from
.Code is modified from here.

The error that i'm facing is that
is not found, specifically :

'NotificationCompat.Builder' does not contain a definition for 'SetCustomBigContentView' and no extension method 'SetCustomBigContentView' accepting a first argument of type 'NotificationCompat.Builder' could be found (are you missing a using directive or an assembly reference?)

Here are my installed packages:

<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v14.Preference" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v4" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.GridLayout" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.Preference" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="" targetFramework="monoandroid70" />

What am i missing ? Is the equivalent function named differently ?

Answer Source

You will need to use the latest pre-release packages for the support libraries. Specifically https://www.nuget.org/packages/Xamarin.Android.Support.v4/24.2.1-rc1 which includes a new assembly: Xamarin.Android.Support.Compat. This will include the method you're looking for:

EX: Looking through Xamarin.Android.Support.Compat in DotPeek

enter image description here

However it's not included in the current stable( as you can see here:

EX: Looking through Xamarin.Android.Support.v4 in DotPeek

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download