コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            if (ActivityCompat.CheckSelfPermission(this,
                                                   Manifest.Permission.AccessFineLocation) != Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.AccessFineLocation },
                                                  940);
            }
            if (ActivityCompat.CheckSelfPermission(this,
                                                   Manifest.Permission.AccessCoarseLocation) != Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.AccessCoarseLocation },
                                                  940);
            }
            if (ActivityCompat.CheckSelfPermission(this,
                                                   Manifest.Permission.Bluetooth) != Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.Bluetooth },
                                                  940);
            }
            if (ActivityCompat.CheckSelfPermission(this,
                                                   Manifest.Permission.BluetoothAdmin) != Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.BluetoothAdmin },
                                                  940);
            }
            if (ActivityCompat.CheckSelfPermission(this,
                                                   Manifest.Permission.Internet) != Permission.Granted)
            {
                ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.Internet },
                                                  940);
            }

            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            InitView();
            //Gets ContactShieldEngine.
            mEngine = ContactShield.GetContactShieldEngine(this);

            //Run CheckContactShieldRunning task method.
            System.Threading.Tasks.Task.Run(() => CheckContactShieldRunning());
        }
コード例 #2
0
 public override void OnCreate()
 {
     base.OnCreate();
     contactShield = ContactShield.GetContactShieldEngine(this);
     Log.Debug(TAG, "BackgroundContackCheckingIntentService onCreate");
 }