Quantcast
Viewing all articles
Browse latest Browse all 4270

Android Gyroscope Hatası

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


el-Vehhab Rızık Bolluğu için


Şirinlik Tılsımı


En etkili korumlardan birisi


Eşler arası Muhabbet ve Cima Tılsımı


Ahiyyen ya hayy şerahiyyen ya kayyum


El-Mütekebbir


Cin Suresi Fazileti


SCCM 2012 Client Installation issue


png şık bayan resimleri, yeni eklenen en güzel png uzantılı bayan resimleri


İFRİT Daveti


Ya şafi


Kara Noel Türkçe Dublaj izle (2019)


Gözlerden Gizlenmek İstersen-Ameli İhfa


Fil suresinin bir hassesi


Bir sorum vardı?


Göz perdesi açma kulak cakrasini açma


Foxtrot Six Türkçe Dublaj izle (2020)


Hadi Gidelim Türkçe dublaj izle (2020)


Şekilli süslü hazır floodlar


Yasin-i Şerif ile Gözlerden Gizlenmek-İhfa