Code example for Display

Methods: getRotation

0
     */ 
    private void onAccelerometerChanged(float gx, float gy, float gz) {
 
        float x = gx, y = gy, z = gz;
 
        switch (mDisplay.getRotation()) {
            case Surface.ROTATION_90: x = -gy; y= gx; break;
            case Surface.ROTATION_180: x = -gx; y = -gy; break;
            case Surface.ROTATION_270: x = gy; y = -gx; break;
        } 
 
        float temp = x * x + y * y + z * z;
        float t = -y /temp;
 
        float tx = t * x;
        float ty = -1 + t * y;
        float tz = t * z;
 
        float length = (float) Math.sqrt(tx * tx + ty * ty + tz * tz);
        float glength = (float) Math.sqrt(temp);
Stop searching for code, let great code find you!  Add Codota to your java IDE