how to write sensor data into file android studio
Java
public class Main extends Activity implements SensorEventListener {
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private FileWriter writer;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activiy_main);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}
public void onStartClick(View view) {
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
public void onStopClick(View view) {
mSensorManager.unregisterListener(this);
}
protected void onResume() {
super.onResume();
writer = new FileWriter("myfile.txt",true);
}
protected void onPause() {
super.onPause();
if(writer != null) {
writer.close();
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
public void onSensorChanged(SensorEvent event) {
float x = event.values[0];
float y = event.values[1];
float z = event.values[2];
writer.write(x+","+y+","+z+"\n");
}
}
Also in Java:
- Title
- show menuitem when menu hovered javafx
- Category
- Java
- Title
- loop while in java
- Category
- Java
- Title
- double round java integer
- Category
- Java
- Title
- how to get the dimensions of a 2d array in java
- Category
- Java
- Title
- how to take space separated input in java
- Category
- Java
- Title
- place.getlatlng() returning null
- Category
- Java
- Title
- java 8 iterating and manipulating list
- Category
- Java
- Title
- java create txt file
- Category
- Java
- Title
- kotlin add value to MutableLiveData
- Category
- Java
- Title
- ndroid.support.v4.content.FileProvider
- Category
- Java
- Title
- java print syntax
- Category
- Java
- Title
- java size of stack
- Category
- Java
- Title
- java return new instance of generic type
- Category
- Java
- Title
- java hashmap get value
- Category
- Java
- Title
- convert char to string java
- Category
- Java
- Title
- socket programming in java
- Category
- Java
- Title
- how to iterate list in java selenium
- Category
- Java
- Title
- how to make a copy of an array java
- Category
- Java
- Title
- phoneword converter
- Category
- Java
- Title
- how to delete character in string java
- Category
- Java
- Title
- java newinstance alternative
- Category
- Java
- Title
- spigot run task later
- Category
- Java
- Title
- java double 2 decimal
- Category
- Java
- Title
- how to add a number to an array in java
- Category
- Java
- Title
- online money transfer andhra bank
- Category
- Java
- Title
- array methods in java
- Category
- Java
- Title
- compile java
- Category
- Java
- Title
- how to make a fixed size array in java
- Category
- Java
- Title
- how to find the divisors of a number in java
- Category
- Java
- Title
- android create snackbar
- Category
- Java
- Title
- spigot kill entity
- Category
- Java
- Title
- get tfidf score for a sentence
- Category
- Java
- Title
- java animated gif example
- Category
- Java
- Title
- take string from keyboard java
- Category
- Java
- Title
- java max
- Category
- Java
- Title
- what it means when create final variable in java
- Category
- Java
- Title
- spigot sounds
- Category
- Java
- Title
- fusion vecteur ordonner java
- Category
- Java
- Title
- java literals w3schools
- Category
- Java
- Title
- thread sleep java
- Category
- Java
- Title
- java stack pop
- Category
- Java
- Title
- gson parse json
- Category
- Java
- Title
- how intent
- Category
- Java
- Title
- équivalent setTimeInterval java
- Category
- Java
- Title
- Compare integers java sort
- Category
- Java
- Title
- creating the functional interface in java
- Category
- Java
- Title
- java queue
- Category
- Java
- Title
- string a int java
- Category
- Java
- Title
- parsedouble java
- Category
- Java
- Title
- find numbers in a string java
- Category
- Java
- Title
- Java Read Files
- Category
- Java
- Title
- java call another constructor
- Category
- Java
- Title
- Java use Base64
- Category
- Java
- Title
- java nested loop
- Category
- Java
- Title
- socket in java
- Category
- Java
- Title
- logging in java
- Category
- Java
- Title
- join two lists java
- Category
- Java
- Title
- how to do sex java
- Category
- Java
- Title
- stackoverflow java enum with constructor
- Category
- Java
- Title
- how to get the checkbox checked value in javafx
- Category
- Java
- Title
- write file java
- Category
- Java
- Title
- treeset java descending order using comparator
- Category
- Java
- Title
- do statement java
- Category
- Java
- Title
- how to check how many anagrams a word has in java
- Category
- Java
- Title
- convert list to array in java
- Category
- Java
- Title
- reverse number in java
- Category
- Java
- Title
- filter and map multiple fields from java stream
- Category
- Java
- Title
- init admob
- Category
- Java
- Title
- list java replace
- Category
- Java
- Title
- simple calculator program in java
- Category
- Java
- Title
- how to find the total of the products added to the shopping cart in java program
- Category
- Java
- Title
- selection sort in java
- Category
- Java
- Title
- how to take max value from priority queue in java
- Category
- Java
- Title
- java syntax
- Category
- Java
- Title
- java 8 hashmap example stackoverflow
- Category
- Java
- Title
- processing audio android
- Category
- Java
- Title
- if statement java
- Category
- Java
- Title
- java arraylist to string
- Category
- Java
- Title
- java define a generic class that produces
- Category
- Java
- Title
- properties java 8 maven in pom xml
- Category
- Java
- Title
- how to compare current date and time with another date and time in android
- Category
- Java
- Title
- compile java to jar in mac
- Category
- Java
- Title
- check leap year in java
- Category
- Java
- Title
- final variables in java
- Category
- Java
- Title
- java swing draw centered text
- Category
- Java
- Title
- java code to get all leaf nodes of a xml file
- Category
- Java
- Title
- add element to stack java
- Category
- Java
- Title
- how to create java jframe in eclipse
- Category
- Java
- Title
- java thread
- Category
- Java
- Title
- java stream order by property
- Category
- Java
- Title
- funzione random in java
- Category
- Java
- Title
- find length of array java
- Category
- Java
- Title
- counting the number of characters in a string java
- Category
- Java
- Title
- google map set default zoom android studio
- Category
- Java
- Title
- java random between two strings
- Category
- Java
- Title
- blurview android github
- Category
- Java
- Title
- java arraylist to array
- Category
- Java
- Title
- Java's BigInteger class
- Category
- Java
- Title
- sqrt in java
- Category
- Java
- Title
- how to import another class in java
- Category
- Java