Commit db649d67 authored by Timothé KOBAK's avatar Timothé KOBAK

premiere page mais crash

parent 4acd6f2a
Pipeline #2722 canceled with stages
...@@ -11,40 +11,17 @@ import android.hardware.SensorManager ...@@ -11,40 +11,17 @@ import android.hardware.SensorManager
import android.util.Log import android.util.Log
import android.widget.EditText import android.widget.EditText
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class galerie : Activity(), SensorEventListener { class galerie : AppCompatActivity() {
private var mSensorManager: SensorManager? = null public override fun onCreate(savedInstanceState: Bundle?) {
private var accelerometer: Sensor? = null
private var V: EditText? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val M1 = LinearLayout(this) val l1 = LinearLayout(this)
M1.orientation = LinearLayout.VERTICAL l1.orientation = LinearLayout.VERTICAL
V = EditText(this) val t1 = TextView(this)
val C = EditText(this) t1.text = "Bienvenue sur 2!"
V!!.setText(" ") l1.addView(t1)
C.setText("VITESSE") setContentView(l1)
M1.addView(C)
M1.addView(V)
setContentView(M1)
mSensorManager = getSystemService(SENSOR_SERVICE) as SensorManager
// on recupere l accelerometre a partir du SensorManager
accelerometer = mSensorManager!!.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
// on associe l ecouteur d’ evenements au SensorManager
mSensorManager!!.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL)
} }
}
override fun onAccuracyChanged(
sensor: Sensor,
accuracy: Int
) { // TODO Auto−generated method stub
}
override fun onSensorChanged(event: SensorEvent) { // TODO Auto−generated method stub
val gammaX = event.values[0]
val gammaY = event.values[1]
val gammaZ = event.values[2]
Log.d("Valeurs accelerometre", "$gammaX,$gammaY,$gammaZ")
V!!.setText(gammaX.toString())
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment