A apty Active Member Licensed User Longtime User May 14, 2014 #1 I have used Erel's code for accelerometer http://www.b4x.com/android/forum/threads/orientation-and-accelerometer.6647/ to display x,y,z values. Now i want to add another value say t, that i can append to the x,y,z values and hence it will become x,y,z,t. The value t is the time of recording accelerometer values (datetime and nanoseconds). In java i can get the same t value this way Code: Copy long MiliTime = System.currentTimeMillis(); long NanoTime = sensorEvent.timestamp; // Time now = new Time(); // now.setToNow(); Time t = new Time(Time.getCurrentTimezone()); t.setToNow(); String date = t.format("%Y/%m/%d %H:%M:%S"); timevalue=String.valueOf(date)+NanoTime I want to display the same in basic4android format. I also want to save this values (i.e. x,y,z,t) in a text file as comma delimited (e.g. -1.2233,0.9766,1.8990,20140514191005xvfcccc where xvfcccc is nanoseconds). Please help me with sample code that can do the above.
I have used Erel's code for accelerometer http://www.b4x.com/android/forum/threads/orientation-and-accelerometer.6647/ to display x,y,z values. Now i want to add another value say t, that i can append to the x,y,z values and hence it will become x,y,z,t. The value t is the time of recording accelerometer values (datetime and nanoseconds). In java i can get the same t value this way Code: Copy long MiliTime = System.currentTimeMillis(); long NanoTime = sensorEvent.timestamp; // Time now = new Time(); // now.setToNow(); Time t = new Time(Time.getCurrentTimezone()); t.setToNow(); String date = t.format("%Y/%m/%d %H:%M:%S"); timevalue=String.valueOf(date)+NanoTime I want to display the same in basic4android format. I also want to save this values (i.e. x,y,z,t) in a text file as comma delimited (e.g. -1.2233,0.9766,1.8990,20140514191005xvfcccc where xvfcccc is nanoseconds). Please help me with sample code that can do the above.
Erel B4X founder Staff member Licensed User Longtime User May 15, 2014 #2 PhoneSensors doesn't expose the event timestamp field. You can set DateTime.TimeFormat and DateFormat to match this format: Code: Copy DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss0000000" Dim n As Long = DateTime.Now Dim time As String = DateTime.Date(n) & DateTime.time(n)) Dim str As String = x & "," & y & "," & z & "," & time Upvote 0
PhoneSensors doesn't expose the event timestamp field. You can set DateTime.TimeFormat and DateFormat to match this format: Code: Copy DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss0000000" Dim n As Long = DateTime.Now Dim time As String = DateTime.Date(n) & DateTime.time(n)) Dim str As String = x & "," & y & "," & z & "," & time