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


Cin suresi vefki


Muhammed İsmi Şerifinin Vefki Cin ve diğer bütün şerlerden korunma


Göz perdesi kaldırma zikri Sonuç alınmıştır.


1001 Esma ile Tövbe


Seyyid Meytatarun-u Davet Etmek İsterseniz Okuyun


SCCM 2012 Client Installation issue


Muhabbet Ve Cimaya Kuvvet


Latiful Habir


Alacağını Almak İçin


Ya Rakib Esmasının Mucizeleri


Heyakili Seb-a Tılsımları - Muhabbet ve Kabul görmek


Ahiyyen ya hayy şerahiyyen ya kayyum


Cin süresi hadimi


Şirinlik Tılsımı


Celcelutiye vefki (Celcelutiye Kübra Daveti)


Hastaya arız olan cini şeytanı maridi yakmak!


Fatiha suresinin müthiş havas esrar ve fazileti .


Karanfil ve Surei İhlas ile CELB


Dehruşiye Azimeti


ibdail Araz vel Cevahir PDF