Accessing the SensorDump API - Android -
has worked on sensordump android app before? i'm trying accelerometer values phone , i've been able dump in csv file on computer. however, i'd add timestamp values , sensordump doesn't provide that.
i can't find documentation online ,and wondering if had tried modify it, or if there's other app out there same (i.e. lets me write sensor values onto file, timestamp).
thanks!
i wrote own sensor dumper, in activity in oncreate:
mstarttime = systemclock.uptimemillis() try { f = new filewriter("/sdcard/download/sensorlog.txt"); if (f != null) { f.append("time;value0;value1;value2\r\n"); } } catch (ioexception e1) { log.e(tag, "cannot open sensorlog file.."); } msensormanager = (sensormanager) this.getsystemservice(context.sensor_service); msteplistener = new sensoreventlistener() { @override public void onaccuracychanged(sensor arg0, int arg1) { } @override public void onsensorchanged(sensorevent event) { sensor sensor = event.sensor; if (sensor.gettype() == sensor.type_accelerometer) { double value0 = event.values[0]; double value1 = event.values[1]; double value3 = event.values[2]; long time = systemclock.uptimemillis() - mstarttime; try { if (f != null) { f.append(time+";"+value0+";"+value1+";"+value2 + "\r\n"); } } catch (ioexception e) { log.e(tag, "cannot write file"); } } } };
this give csv text file, timestamp , 3 values.
ps. don't forget ask sd-card write permission.
also declare first:
filewriter f; private sensormanager msensormanager; private sensoreventlistener msteplistener;
and don't forget close file..
try { f.close(); } catch (ioexception e) { log.e(tag, "cannot close file"); }
Comments
Post a Comment