Esempio n. 1
0
        protected override void OnDestroy()
        {
            base.OnDestroy();
            try
            {
                StopTimer();
                StopDataManager();
                if (cameraManager != null)
                {
                    cameraManager.Error -= HandleError;
                    cameraManager.PictureTaken -= CameraManager_PictureTaken;
                    cameraManager.Close();
                    cameraManager.Dispose();
                    cameraManager = null;
                }

                if (wakeLock != null)
                {
                    wakeLock.Release();
                    wakeLock.Dispose();
                    wakeLock = null;
                }

                if (locTrackerGPS != null)
                {
                    locTrackerGPS.Dispose();
                }

                if (locTrackerNetwork != null)
                {
                    locTrackerNetwork.Dispose();
                }
            }
            catch (Exception e)
            {
                showError(e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 起動時
        /// </summary>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // 画面の向きを固定する
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;

            // 各種フラグ設定
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            //ウェイクロック
            using (PowerManager pm = (PowerManager)GetSystemService(Service.PowerService))
            {
                wakeLock = pm.NewWakeLock(WakeLockFlags.ScreenDim, PackageName);
                wakeLock.Acquire();
            }

            //設定読み込み
            settings = Settings.Load(this);

            //カメラを開く
            cameraManager = new CameraManager();
            cameraManager.PictureTaken += CameraManager_PictureTaken;
            cameraManager.Open();

            // カメラ表示設定
            cameraSurfaceView = FindViewById<SurfaceView>(Resource.Id.surfaceView1);
            cameraSurfaceView.Holder.AddCallback(this);
            cameraSurfaceView.Holder.SetType(SurfaceType.PushBuffers);

            //位置情報を開く
            locTrackerGPS = new LocationTracker(this, LocationManager.GpsProvider);
            locTrackerGPS.Start();
            locTrackerNetwork = new LocationTracker(this, LocationManager.NetworkProvider);
            locTrackerNetwork.Start();

            // 各種イベントを登録する
            SetupEvents();
        }