Quantcast
Channel: BTSoru.com - Bilisim ve Yazilim Teknolojileri Soru/Cevap Platformu - latest questions
Viewing all articles
Browse latest Browse all 4270

Android Gyroscope Hatası

$
0
0

public class MainActivity extends AppCompatActivity { ImageView img = null; private SensorManager mSensorManager; private Sensor mSensor; float buttonX; float buttonY; float viewWidth; float viewHeight; EditText webin; TextView TextX; TextView TextY; TextView TextZ; float x; float y; float z;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

/*  Display display = getWindowManager().getDefaultDisplay();
    int imageSize = img.getWidth();
    Point size = new Point();
    display.getSize(size);
    viewWidth = size.x;
    viewHeight = size.y; */

}

private float mAccel; // acceleration apart from gravity
private float mAccelCurrent; // current acceleration including gravity
private float mAccelLast; // last acceleration including gravity

private final SensorEventListener mSensorListener = new SensorEventListener() {
    public void onSensorChanged(SensorEvent se) {
        float x = se.values[0];
        TextView TextX = (TextView) findViewById(R.id.TextX);
        TextX.setText(String.valueOf(x));
        float y = se.values[1];
        TextView TextY = (TextView) findViewById(R.id.TextY);
        TextY.setText(String.valueOf(y));
        float z = se.values[2];
        TextView TextZ = (TextView) findViewById(R.id.TextZ);
        TextZ.setText(String.valueOf(z));

        ImageView img = (ImageView) findViewById(R.id.imageView);

        //   TextX.setText(String.valueOf(x));  //ekran sallayınca x koordinatı değişecek.
        // float y = se.values[1];

        //  TextY.setText(String.valueOf(y)); //ekranı sallayınca y koordinati değişecek.
        // float z = se.values[2];

        //   TextZ.setText(String.valueOf(z)); //ekranı sallayınca z koordinatı değişecek.
        mAccelLast = mAccelCurrent;
        mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
        float delta = mAccelCurrent - mAccelLast;
        mAccel = mAccel * 0.9f + delta; // perform low-cut filter

        //img.setZ(z);

       /* if (buttonX < viewWidth) { */
        //    buttonX -= x;
      /*  } */

       /* if (buttonY < viewHeight) { */
        //   buttonY += y;
    /*    } */

        // img.setX(buttonX);
        // img.setY(buttonY);

    }

Kod hata vermiyor ama nesne hareket etmiyor neden?


Viewing all articles
Browse latest Browse all 4270

Trending Articles


huddam daveti


Tekasür Suresi


"Yâ Kuddûs!" Esması Havâs ve Esrârı


Kasemi Mübelliğa


Peri44


Kuvvetli muhabbet ve aşk tılsımı


El-Mütekebbir


Papaz büyüsü


SCCM 2012 Client Installation issue


Zilhicce Ayının Namaz Duası ÖNEMLİ