Forum Xamarin.Android

Not Able to Turn On the Notification Blink LED ( Front ) - Xamarin.Android

PoorneshV15PoorneshV15 Member ✭✭
edited April 2019 in Xamarin.Android

I am not able to control or turn on the Notification Blink . I have followed the following approach -

namespace Notifications
    [Activity(Label = "Notifications", MainLauncher = true, Icon = "@drawable/Icon")]
    public class MainActivity : AppCompatActivity
        // Unique ID for our notification: 
        static readonly int NOTIFICATION_ID = 1000;
        static readonly string CHANNEL_ID = "location_notification";
        internal static readonly string COUNT_KEY = "count";

        // Number of times the button is tapped (starts with first tap):
        int count = 1;

        protected override void OnCreate(Bundle bundle)


            var button = FindViewById<Button>(Resource.Id.MyButton);
            button.Click += ButtonOnClick;

        // Handler for button click events.
        void ButtonOnClick(object sender, EventArgs eventArgs)
            // Pass the current button press count value to the next activity:
            var valuesForActivity = new Bundle();
            valuesForActivity.PutInt(COUNT_KEY, count);

            // When the user clicks the notification, SecondActivity will start up.
            var resultIntent = new Intent(this, typeof(SecondActivity));

            // Pass some values to SecondActivity:

            // Construct a back stack for cross-task navigation:
            var stackBuilder = TaskStackBuilder.Create(this);

            // Create the PendingIntent with the back stack:            
            var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int) PendingIntentFlags.UpdateCurrent);

            // Build the notification:
            var builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                          .SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it
                          .SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
                          .SetContentTitle("Button Clicked") // Set the title
                          .SetNumber(count) // Display the count in the Content Info
                          .SetSmallIcon(Resource.Drawable.ic_stat_button_click) // This is the icon to display
                          .SetContentText($"The button has been clicked {count} times.")
                          .SetLights(unchecked((int)0xFFFFFFF0), 500,1000)
                          .Build(); // the message to display.
            builder.Defaults = 0;

            builder.LedARGB =unchecked((int) 0xff0000ff);
            builder.LedOnMS = 1000;

            // Finally, publish the notification:
            var notificationManager = NotificationManagerCompat.From(this);
            notificationManager.Notify(NOTIFICATION_ID, builder);

            // Increment the button press count:

        void CreateNotificationChannel()
            if (Build.VERSION.SdkInt < BuildVersionCodes.O)


            var name = Resources.GetString(Resource.String.channel_name);
            var description = GetString(Resource.String.channel_description);
            var channel = new NotificationChannel(CHANNEL_ID, name, NotificationImportance.Default)
                              Description = description

            var notificationManager = (NotificationManager) GetSystemService(NotificationService);

I have also tried setting the led color using Notification channel , but it didn't blink nor changed the color. Any Suggestions?

Best Answer


Sign In or Register to comment.