コード例 #1
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            try
            {
                if (AppStatus.UserLogged == null)
                {
                    MyTrapBDConfig.Initialize();

                    AppStatus.UserLogged = UserApiService.GetUserLogged();
                }

                if (AppStatus.UserLogged != null)
                {
                    Token = AppStatus.UserLogged.Token;

                    apiClient = new GoogleApiClient.Builder(Context, this, this).AddApi(LocationServices.API).Build();

                    locRequest = new LocationRequest();

                    apiClient.Connect();

                    IsStarted = true;
                }
                else
                {
                    StopSelf();
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }

            return(StartCommandResult.Sticky);
        }
コード例 #2
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Xamarin.Forms.Forms.Init(e);

            await InitNotificationsAsync();

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    AppStatus.UserLogged = UserApiService.GetUserLogged();

                    if (AppStatus.UserLogged == null)
                    {
                        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                    }
                    else
                    {
                        AppShell appShell = new AppShell();

                        appShell.AppFrame.Navigate(typeof(HomePage), e.Arguments, new Windows.UI.Xaml.Media.Animation.SuppressNavigationTransitionInfo());

                        Window.Current.Content = appShell;
                    }
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone)
            {
                await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync();
            }
        }
コード例 #3
0
        private void LoadUser()
        {
            AppStatus.UserLogged = UserApiService.GetUserLogged();

            if (AppStatus.UserLogged == null)
            {
                StartActivity(typeof(LoginActivity));
            }
            else
            {
                MyTrapDroidFunctions.OpenHome(this);
            }
        }
コード例 #4
0
        public override void OnReceive(Context context, Intent intent)
        {
            //Toast.MakeText(context, intent.Action, ToastLength.Long).Show();

            try
            {
                if (AppStatus.UserLogged == null)
                {
                    MyTrapBDConfig.Initialize();

                    AppStatus.UserLogged = UserApiService.GetUserLogged();
                }

                if (AppStatus.UserLogged != null)
                {
                    PositionService.Start(context);
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }
        }