java - Magnetic sensor and image rotation in Android -


trying build magnetic compass, have following code.

public void onsensorchanged(sensorevent event) {     imagecompass = (imageview) findviewbyid(r.id.imagemapdrawview);     bitmap myimg = bitmapfactory.decoderesource(getresources(), r.drawable.compass);     matrix matrix = new matrix();     matrix.postrotate(event.values[0] );     bitmap rotated = bitmap.createbitmap(myimg, 0, 0, myimg.getwidth(), myimg.getheight(),             matrix, true);     imagecompass.setimagebitmap(rotated); } 

i have following questions, a. guess event.values[0] in degree? not in radian? b. want image image view , rotate around center of image, telling that? c. want draw image (an indicator on top of image), can this? have compass image in image view , want draw image on top. can't redraw whole view. how can achieve it?

a. check http://developer.android.com/reference/android/hardware/sensorevent.html.

the length , contents of values array depends on sensor type being monitored.

sensor.type_accelerometer in m/s² sensor.type_magnetic_field in ut (micro tesla) sensor.type_gyroscope in rad/s 

and go on sensors (check link).

also, interface sensorlistener deprecated since api level 3. should use sensoreventlistener instead.

b , c. should consider using opengl es drawing images. specially opengl es 2.0 gives details , ways manipulate images easy let need.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -