android-sensors

getSystemServices is undefined when called in a Fragment?

拥有回忆 提交于 2019-11-30 12:39:18
问题 I want TextViews to display the sensors readings in a Fragment . When trying to initialize the SensorManager the getSystemServices is undefined in the Fragment , eclipse says.Why and how to fix it. Fragment public class FragSensors extends Fragment { private TextView accXTv, accYTv, accZTv; private SensorManager sensorManager; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater

Parsing data from hdp device for android (API 15)

大憨熊 提交于 2019-11-30 10:38:43
I am using the HDP Sample and I have a Blood pressure sensor (http://www.andonline.com/medical/products/details.php?catname=&product_num=UA-767PBT-C). I get the data from it, but I don't know how to parse it into something human readable. this is what I tried until now with something like: while(fis.read(data) > -1) { String value = null; BigInteger bi = new BigInteger(data); // for(byte b:data){ // value+=b; // } Log.d("read data binary", "the data "+bi.toString(2)); Log.d("read data decimal", "the data "+bi.toString()); Log.d("read data hexa", "the data "+bi.toString(16)); Log.d("read data

Android light sensor - detect significant light changes

穿精又带淫゛_ 提交于 2019-11-30 10:06:23
I am new to sensor use in android and now a bit confused. I need to perform some actions only if there's a significant light change, e.g. the light was turned on in a dark room. I have a pretty simple default implementation so far. How can I tell the system I only want to react to a significant light change? public class MainActivity extends Activity implements SensorEventListener { private SensorManager mSensorManager; private Sensor mLight; private RelativeLayout mLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Having trouble reading heart rate sensor from Moto 360 - Android Wear

耗尽温柔 提交于 2019-11-30 10:02:28
Has anyone successfully read the heart rate sensor from the Moto 360? mSensorManager = ((SensorManager)getSystemService(SENSOR_SERVICE)); mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE); I am getting an error that states "SensorManager﹕ sensor or listener is null" I know the Gear Live uses a different ID other than Sensor.TYPE_HEART_RATE...I'm wondering if that's the case with the Moto 360. I tried a sensor value of 65538 which reports itself as a "Wellness Sensor" but that does not appear to return data either. Any advice would be appreciated. I am doing the same on

How can i replace type_orientation (is deprecated) for android 4.0.3?

你离开我真会死。 提交于 2019-11-30 07:51:10
问题 Hello I want to use the type type_orientation but it is deprecated for the android 4.0.3 . I use it for the augmented reality. I tried to find on the net but without success. My application works but my text inside stay in the same place! Here my code: @Override protected void onStart() { super.onStart(); sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensorLstr = createListener(); sensorMngr.registerListener(sensorLstr, sensorMngr.getDefaultSensor(Sensor.TYPE

Get device angle by using getOrientation() function

不羁岁月 提交于 2019-11-30 07:13:26
I was using Sensor.TYPE_ORIENTATION to determine current angle of device but TYPE_ORIENTATION is deprecated on API version 8 . In SensorManager manual it refers to getOrientation() function in order to use TYPE_ORIENTATION . Here is the manual Here is my old code : public void onSensorChanged(SensorEvent event) { Log.d("debug","Sensor Changed"); if (event.sensor.getType()==Sensor.TYPE_ORIENTATION) { Log.d("debug",Float.toString(event.values[0])); float mAzimuth = event.values[0]; float mPitch = event.values[1]; float mRoll = event.values[2]; Log.d("debug","mAzimuth :"+Float.toString(mAzimuth))

Proximity sensor on Galaxy S4 (Air Gestures)

那年仲夏 提交于 2019-11-30 03:42:54
The new Samsung Galaxy S4 have and interesting new type of gestures called " Air Gesture " that use an infrared sensor to process users hand movement in front of the screen, adding a " pre-touch "/" proximity " event, in wich the fingers are detected before the touch. I'd like to use this " Floating Touch " event in one of my apps. I searched both on Google and in the Samsung Developers Center, but I coudnt find any API or information about that. Are the API available or is too early? Does someone have any link/info? http://www.samsung.com/global/microsite/galaxys4/lifetask.html#page=airview

getSystemServices is undefined when called in a Fragment?

微笑、不失礼 提交于 2019-11-30 03:07:40
I want TextViews to display the sensors readings in a Fragment . When trying to initialize the SensorManager the getSystemServices is undefined in the Fragment , eclipse says.Why and how to fix it. Fragment public class FragSensors extends Fragment { private TextView accXTv, accYTv, accZTv; private SensorManager sensorManager; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View v = inflater.inflate(R.layout.frag_sensors, container, false); accXTv = (TextView) v.findViewById(R.id.accXValue); accYTv

How is it possible that Google Fit app measures number of steps all the time without draining battery?

∥☆過路亽.° 提交于 2019-11-29 22:50:57
The Google Fit app, when installed, measures the duration you are walking or running, and also the number of steps all the time . However, strangely, using it does not seem to drain the battery. Other apps like Moves which seems to record number of steps pretty accurately declares that it uses a lot of power because of it constantly monitoring the GPS and the accelerometer. I imagine several possibilities: Wakes up the phone every minute or so, then analyses the sensors for a few seconds and then sleeps again. However it seems that the records are pretty accurate to the minute, so the waking

Android natural sensor orientation help

≡放荡痞女 提交于 2019-11-29 22:43:48
问题 I am trying to accomplish Reto Meier's recommended way for keeping the screen orientation from changing. The slides from his talk during Google IO (see #23) can be found in Android Protips: Where to Download the Slides and Code Snippets . I have stepped through the code and it setting the values, but the screen orientation still changes. FYI, I register this listener in the Application. Here is my code: final SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sm