Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android


 
Herramientas
  #1  
Viejo 02/03/15, 20:11:33
Avatar de manuelhtc
manuelhtc manuelhtc no está en línea
Usuario poco activo
Mensajes: 40
 
Fecha de registro: abr 2008
Mensajes: 40
Modelo de smartphone: htc diamond
Mencionado: 1 comentarios
Tagged: 0 hilos
CountDownTimer y registerListener

Hola,

estoy teniendo problemas al registrar un listener desde que lo he metido dentro de un CountDownTimer.

acelerometroRegistrado = mSensorManager.registerListener(this,
mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

El problema es que ahora cuando pongo this, intenta registrarlo en el CountDownTimer. Ahora que tengo el código dentro del CountDownTimer, ¿qué debo poner en vez de this?

Gracias.

public void startStopAcelerometer() {
if (acelerometroRegistrado == false) {
new CountDownTimer(10000, 1000) {

public void onTick(long millisUntilFinished) {
txtOut4.setText("Faltan: " + millisUntilFinished / 1000
+ " segundos");
}

public void onFinish() {
txtOut4.setText("Adelante!");
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
mAccelerometer = mSensorManager
.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
// Lo activamos dandole las características standars.
acelerometroRegistrado = mSensorManager.registerListener(this,
mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);


button1.setText("Stop");
}
}.start();

} else {
mSensorManager.unregisterListener(this);
acelerometroRegistrado = false;
button1.setText("Start");
}
}
Responder Con Cita


Respuesta

Estás aquí
Regresar   HTCMania > Todo sobre Android > Programación y Desarrollo para Android

Herramientas

Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 08:30:50 (GMT +2)

Cookies settings
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007