当前位置: 首页>>代码示例>>C#>>正文


C# Bundle.GetFloat方法代码示例

本文整理汇总了C#中Bundle.GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Bundle.GetFloat方法的具体用法?C# Bundle.GetFloat怎么用?C# Bundle.GetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bundle的用法示例。


在下文中一共展示了Bundle.GetFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

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

			SetContentView (Resource.Layout.Sensors);

			trackButton = FindViewById<Button> (Resource.Id.trackButton);
			stepCount = FindViewById<TextView> (Resource.Id.stepCount);

			// create a sensor manager to schedule batches of sensor data
			senMgr = (SensorManager) GetSystemService (SensorService);

			// update state from orientation change
			if (bundle != null)
			{
				count = bundle.GetFloat ("step_count", 0);
				if (bundle.GetBoolean ("visible", false)) {
					visible = true;
					stepCount.Text = count.ToString ();
				}
				Log.Debug(GetType().FullName, "Recovered instance state");
			}


			// This button gets the user's step count since the last time the device was rebooted
			trackButton.Click += (o, e) => {
				// get the step counter sensor via the SensorManager
				counter = senMgr.GetDefaultSensor (SensorType.StepCounter);

				// button's been clicked, so counter visibility gets set to true
				visible = true;

				// This sensor is only available on Nexus 5 and Moto X at time of writing
				// The following line will check if the sensor is available explicitly:
				bool counterAvailabe = PackageManager.HasSystemFeature(PackageManager.FeatureSensorStepCounter);
				Log.Info("SensorManager", "Counter available");

				if (counterAvailabe && counter != null) {
					// Set sensor delay to normal, the default rate for batching sensor data
					senMgr.RegisterListener(this, counter, SensorDelay.Normal);
					Toast.MakeText(this,"Count sensor started",ToastLength.Long).Show();
				} else {
					Toast.MakeText(this, "Count sensor unavailable", ToastLength.Long).Show();
				}
			};

		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:47,代码来源:SensorsActivity.cs

示例2: OnCreate

        protected override void OnCreate(Bundle savedInstanceState)
        {
            powerManager = (PowerManager)GetSystemService(Context.PowerService);
            wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MyWakeLock");
            wakeLock.Acquire();

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Pedometer);

            chrono = FindViewById<Chronometer>(Resource.Id.chronometer1);
            sensorManager = (SensorManager)GetSystemService(Context.SensorService);
            stepsTextView = FindViewById<TextView>(Resource.Id.pedometer);
            caloriesTextView = FindViewById<TextView>(Resource.Id.calories);
            speedTextView = FindViewById<TextView>(Resource.Id.speed);
            distanceTextView = FindViewById<TextView>(Resource.Id.distance);
            timeTextView = FindViewById<TextView>(Resource.Id.time);

            if (savedInstanceState != null)
            {
                steps = savedInstanceState.GetInt("steps", 0);
                calories = savedInstanceState.GetFloat("calories", 0.0f);
                speed = savedInstanceState.GetFloat("speed", 0.0f);
                distance = savedInstanceState.GetFloat("distance", 0.0f);
                chrono.Base = savedInstanceState.GetLong("time", SystemClock.ElapsedRealtime());
                run = savedInstanceState.GetBoolean("run", false);
            }

            chrono.Format = "00:0%s";
            chrono.OnChronometerTickListener = this;

            int h = 480;
            mYOffset = h * 0.5f;
            mScale[0] = -(h * 0.5f * (1.0f / (SensorManager.StandardGravity * 2)));
            mScale[1] = -(h * 0.5f * (1.0f / (SensorManager.MagneticFieldEarthMax)));

            if (run)
            {
                refreshTextViews();
                sensorsListenerRegister();
                chrono.Start();
            }
        }
开发者ID:236422,项目名称:Krokomierz,代码行数:42,代码来源:PedometerActivity.cs


注:本文中的Bundle.GetFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。