コード例 #1
0
        protected override void OnDestroy()
        {
            Log.Debug(TAG, "OnDestroy: Location app is becoming inactive");
            base.OnDestroy();

            // Stop the location service:
            AppLS.StopLocationService();
        }
コード例 #2
0
 public override async void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
 {
     switch (requestCode)
     {
     case RequestLocationId: {
         if (grantResults[0] == (int)Android.Content.PM.Permission.Granted)
         {
             Toast.MakeText(this, "Special permissions granted", ToastLength.Short).Show();
             Log.Debug(TAG, "User granted permission for location.");
             AppLS.StartLocationService();
         }
         else
         {
             //Permission Denied :(
             Toast.MakeText(this, "Special permissions denied", ToastLength.Short).Show();
         }
     }
     break;
     }
     //base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 }
コード例 #3
0
ファイル: AppLS.cs プロジェクト: OscarAlmeida-Newsoft/App
 static AppLS()
 {
     Current = new AppLS();
 }
コード例 #4
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Pregunta por permisos de camera
            await TryToGetPermissions();

            //Se configura el logueo de errores
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            //Se registra el reporte de errores de hockeyapp
            HockeyApp.Android.CrashManager.Register(this, "ded4af869e434fc3a04cdf3269d86680");
            HockeyApp.Android.Metrics.MetricsManager.Register(this, Application, "ded4af869e434fc3a04cdf3269d86680");

            MessagingCenter.Subscribe <StartLongRunningTaskMessage>(this, "StartLongRunningTaskMessage", message => {
                var intent = new Intent(this, typeof(LongRunningTaskService));
                StartService(intent);
            });

            DisplayCrashReport();

            MessagingCenter.Subscribe <StopLongRunningTaskMessage>(this, "StopLongRunningTaskMessage", message => {
                var intent = new Intent(this, typeof(LongRunningTaskService));
                StopService(intent);
            });

            // Start the location service:
            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == (int)Permission.Granted)
            {
                Log.Debug(TAG, "User already has granted permission.");
                AppLS.StartLocationService();
            }
            //else {
            //    Log.Debug(TAG, "Have to request permission from the user. ");
            //    RequestLocationPermission();
            //}

            //Notification Opened Delegate
            Com.OneSignal.OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(string message, System.Collections.Generic.Dictionary <string, object> additionalData, bool isActive) {
                try {
                    System.Console.WriteLine("OneSignal Notification opened:\nMessage: {0}", message);

                    if (additionalData != null)
                    {
                        if (additionalData.ContainsKey("customKey"))
                        {
                            System.Console.WriteLine("customKey: {0}", additionalData["customKey"]);
                        }

                        System.Console.WriteLine("additionalData: {0}", additionalData);
                    }
                } catch (System.Exception e) {
                    System.Console.WriteLine(e.StackTrace);
                }
            };



            global::Xamarin.Forms.Forms.Init(this, bundle);
            DevExpress.Mobile.Forms.Init();
            Com.OneSignal.OneSignal.Init();
            LoadApplication(new App());

            var container = new SimpleContainer();

            container.Register <IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register <IDisplay>(t => t.Resolve <IDevice>().Display);
            container.Register <INetwork>(t => t.Resolve <IDevice>().Network);

            //20191007 - Se comenta para que no salga notificacion de gps siempre
            //No estaba incluido en version anteror
            //StartService(new Intent(this, typeof(GPSService)));
            //// register GPS Service
            //RegisterService();
        }