writing android sensor data to XML file
hi i am developing an application that read data from sensors and write those data to an XML file when you press a key. i have 2 activity one for button and another is an Activity who impl开发者_StackOverflow中文版ements sensorEventListener. the problem is my main activity is button and couldn't get data from event listener activity. i think the listener activity is not active but when i create an intent and start activity with that intent the program stop working. the button is able to create XML file solely. so how could i read sensor data from sensors,and how to send them to XML file when the button got clicks ?
thanks
From what u described I think it might be best to have a single activity (with the button to start) and have this activity listening to the sensor values all the time while storing the latest entry in memory.
In the onResume
method of your you might want to register the listener (this). Don't forget to unRegister
, once you leave/pause the activity.
Once you press the button, write out the cached sensor values into your XML file.
精彩评论