From a54d53a656079ca26f7f7ee87a58ec8cc11b3283 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Wed, 13 Mar 2013 14:58:01 -0700 Subject: [PATCH] Revert "Add Trigger Sensor API Demo." This reverts commit 50435d3e6f13f1faca9d743bd4f29791e8a4931d. --- samples/ApiDemos/AndroidManifest.xml | 7 -- .../ApiDemos/res/layout/trigger_sensors.xml | 31 ----- samples/ApiDemos/res/values/strings.xml | 8 -- .../android/apis/os/TriggerSensors.java | 113 ------------------ 4 files changed, 159 deletions(-) delete mode 100644 samples/ApiDemos/res/layout/trigger_sensors.xml delete mode 100644 samples/ApiDemos/src/com/example/android/apis/os/TriggerSensors.java diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index a201523d9..f4e77e037 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -1198,13 +1198,6 @@ - - - - - - - diff --git a/samples/ApiDemos/res/layout/trigger_sensors.xml b/samples/ApiDemos/res/layout/trigger_sensors.xml deleted file mode 100644 index c4156e0c5..000000000 --- a/samples/ApiDemos/res/layout/trigger_sensors.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - /> - diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index 8b28a1d9d..c9c347eab 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -877,14 +877,6 @@ Play Audio from Local File Play Audio from Resources - - - - Significant Motion Sensor Not Detected - Significant Motion Detected - Significant Motion Enabled - Signification Motion Auto Disabled - diff --git a/samples/ApiDemos/src/com/example/android/apis/os/TriggerSensors.java b/samples/ApiDemos/src/com/example/android/apis/os/TriggerSensors.java deleted file mode 100644 index 7d4b4168c..000000000 --- a/samples/ApiDemos/src/com/example/android/apis/os/TriggerSensors.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.android.apis.os; - -import android.app.Activity; -import android.content.Context; -import android.view.View; -import android.hardware.Sensor; -import android.hardware.TriggerEvent; -import android.hardware.TriggerEventListener; -import android.hardware.SensorManager; -import android.os.Bundle; -import android.widget.TextView; -import com.example.android.apis.R; - -/** - *

Application showing the Trigger Sensor API for the Significant Motion sensor.

- -

This demonstrates the {@link android.hardware.SensorManager android.hardware.SensorManager - android.hardware.TriggerEventListener} class. - -

Demo

-OS / TriggerSensors - -

Source files

- * - * - * - * - * - *
src/com.example.android.apis/os/TriggerSensors.javaTriggerSensors
- */ - - -class TriggerListener extends TriggerEventListener { - private Context mContext; - private TextView mTextView; - - TriggerListener(Context context, TextView textView) { - mContext = context; - mTextView = textView; - } - - @Override - public void onTrigger(TriggerEvent event) { - if (event.values[0] == 1) { - mTextView.append(mContext.getString(R.string.sig_motion) + "\n"); - mTextView.append(mContext.getString(R.string.sig_motion_auto_disabled) + "\n"); - } - // Sensor is auto disabled. - } -} - -public class TriggerSensors extends Activity { - private SensorManager mSensorManager; - private Sensor mSigMotion; - private TriggerListener mListener; - private TextView mTextView; - - @Override - protected void onResume() { - super.onResume(); - if (mSigMotion != null && mSensorManager.requestTriggerSensor(mListener, mSigMotion)) - mTextView.append(getString(R.string.sig_motion_enabled) + "\n"); - } - - @Override - protected void onPause() { - super.onPause(); - // Call disable only if needed for cleanup. - // The sensor is auto disabled when triggered. - if (mSigMotion != null) mSensorManager.cancelTriggerSensor(mListener, mSigMotion); - } - - - /** - * Initialization of the Activity after it is first created. Must at least - * call {@link android.app.Activity#setContentView setContentView()} to - * describe what is to be displayed in the screen. - */ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.trigger_sensors); - mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); - mSigMotion = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION); - mTextView = (TextView)findViewById(R.id.text); - mListener = new TriggerListener(this, mTextView); - if (mSigMotion == null) { - mTextView.append(getString(R.string.no_sig_motion) + "\n"); - } - } - - @Override - protected void onStop() { - if (mSigMotion != null) mSensorManager.cancelTriggerSensor(mListener, mSigMotion); - super.onStop(); - } -}