Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android activity over default lock screen using xamarin

I wanted to know how exactly i can add WindowManager's LayoutParams flag inside C# code of xamarin.

For example we can do it in Android by code given below.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
like image 853
RPB Avatar asked Apr 20 '26 01:04

RPB


1 Answers

Like so:

namespace SampleCode
{
    [Activity (Label = "SampleCode", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            Window.AddFlags(WindowManagerFlags.KeepScreenOn|
                WindowManagerFlags.DismissKeyguard|
                WindowManagerFlags.ShowWhenLocked|
                WindowManagerFlags.TurnScreenOn);       
        }
    }
}
like image 53
Alex.F Avatar answered Apr 22 '26 15:04

Alex.F



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!