android studio - Computing device's angle -


i'd compute device's angle, when it's tilted @ bottom edges left , right, using accelerometer , magnetometer. save highest value i've received , show in textview.

this how tried:

 public void onsensorchanged(sensorevent event) {      if (event.sensor.gettype() == sensor.type_accelerometer)         mgravity = event.values;     if (event.sensor.gettype() == sensor.type_magnetic_field)         mgeomagnetic = event.values;     if (mgravity != null && mgeomagnetic != null) {         float r[] = new float[9];         float i[] = new float[9];          boolean success = sensormanager.getrotationmatrix(r, i, mgravity, mgeomagnetic);         if (success) {             float orientation[] = new float[3];             sensormanager.getorientation(r, orientation);             playerangle = (float) math.todegrees(orientation[3]);              tv.settext(string.valueof(playerangle));           } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -