0

I need to check before show notification that app in sleep mode. I'm use notification as alarm and it is not necessary to show notification if app active Is it possible to check app sleep or not?

var builder = new Notification.Builder(context)
                .SetPriority((int)NotificationPriority.High)
                .SetVisibility(NotificationVisibility.Public)
                .SetDefaults(NotificationDefaults.Vibrate)
                .SetCategory(Notification.CategoryAlarm)
                .SetContentIntent(contentIntent)
                .SetSmallIcon(Resource.Drawable.icon)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                .SetAutoCancel(true);

            var notification = builder.Build();
            manager.Notify(0, notification);
Rodion
  • 340
  • 7
  • 25
  • 1
    There is no direct way (as far as I know) to get a value for this. This answer should bring you to the right way: http://stackoverflow.com/a/5504711/2653134 – Joehl Aug 09 '16 at 07:37
  • You can use the ActivityMananger to geht the current foreground App https://stackoverflow.com/questions/2166961/determining-the-current-foreground-application-from-a-background-task-or-service – Thommy Aug 09 '16 at 08:21

0 Answers0