Rish
Rish

Reputation: 23

Notifications on xamarin. Android.Resource.Drawable.SymActionEmail error

Hi I am a polytechnic student. I am totally new to xamarin so I would appreciate any help.

So my problem is I recently followed this tutorial on how to create notifications on xamarin android and encountered this problem in the MyBroadcastReceiver.cs. It says resource.drawable does not contain a definition for 'SymActionEmail' under the create notification comment. Any help to fix this would be appreciated.

Upvotes: 2

Views: 371

Answers (2)

AlexTsy
AlexTsy

Reputation: 23

You can only use global contextual keyword directly in your code

var notification = new Notification(global::Android.Resource.Drawable.SymActionEmail, title);

Upvotes: 1

Martin Zikmund
Martin Zikmund

Reputation: 39092

I think the problem lies in the fact that the namespace where this class resides ands with .Android suffix. This means that the Android.Resource.Drawable does not actually reference the Xamarin Android's own Resource.Drawable class but your project-specific Resource.Drawable class. To overcome you will need to either rename the namespace of this class not to end with .Android or add a using alias for the default Android namespace:

//add this to the using statements in this file
using Sys = Android;
...
//now use the following in your code 
//to use Xamarin Android's built-in Resource.Drawable class
var notification = new Notification( Sys.Resource.Drawable.SymActionEmail, title );

Upvotes: 1

Related Questions