android-developers
[Arriba] [Todas las Listas]

[android-developers] Re: SensorEvent timestamp No siempre actualizar

To: android-developers@xxxxxxxxxxxxxxxx
Subject: [android-developers] Re: SensorEvent timestamp No siempre actualizar
From: josean1968 <josean1968@xxxxxxxxx>
Date: Fri, 28 Oct 2011 15:38:30 -0700 (PDT)
Delivery-date: Mon, 31 Oct 2011 14:00:58 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:date:from:reply-to:to:message-id:in-reply-to:references :subject:mime-version:x-original-sender:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=OfVXYy8mbWpdoYI/Gd2Xi4ic9TCrExx5dxXrnBvyB4A=; b=fYO1NEYcaIZopsnQNOPK4NkvSx8JH3jWTpn6jae6i4I4LbSbU9L2Oq7goODaBJqm03 N5IUBjxH5MdcOpa7/Nf21P9uagWyVG1lCRlg4ulU/fwA1QOXurC3v+XbrWvttnDy3mdT 9sUnMnN8bbwLBqgJDPDobUJ3a73taJRFfyv3M=
Envelope-to: traductor@xxxxxxxxxxx
In-reply-to: <27669871.2049.1319635856130.JavaMail.geo-discussion-forums@yqnv12>
List-archive: <http://groups.google.com/group/android-developers?hl=en_US>
List-help: <http://groups.google.com/support/?hl=en_US>, <mailto:android-developers+help@googlegroups.com>
List-id: <android-developers.googlegroups.com>
List-post: <http://groups.google.com/group/android-developers/post?hl=en_US>, <mailto:android-developers@googlegroups.com>
List-subscribe: <http://groups.google.com/group/android-developers/subscribe?hl=en_US>, <mailto:android-developers+subscribe@googlegroups.com>
List-unsubscribe: <http://groups.google.com/group/android-developers/subscribe?hl=en_US>, <mailto:android-developers+unsubscribe@googlegroups.com>
Mailing-list: list android-developers@xxxxxxxxxxxxxxxx; contact android-developers+owners@xxxxxxxxxxxxxxxx
References: <27669871.2049.1319635856130.JavaMail.geo-discussion-forums@yqnv12>
Reply-to: android-developers@xxxxxxxxxxxxxxxx
Sender: android-developers@xxxxxxxxxxxxxxxx
Hola,

tienes esto:

...
    Privado *SensorEvent *lastEvent;
...

@*Override
    Público *void *onSensorChanged(*SensorEvent acontecimiento)
        #cnj (*lastEvent == *null)
            #unknown{^*lastEvent = acontecimiento;
            regreso;
        }
        
        *Log.*v(TAG, "*dT [" + Hilo.*currentThread().*getName() + "]: " + 
(Acontecimiento.*timestamp - *lastEvent.*timestamp));
    }

----------------

El problema es que el "*onSensorChanged()" el método puede ser invocado 
*concurrently porque es un acontecimiento *listener.
Declarar una variable local y copiar el valor (no justo un *pointer al 
objeto):

@*Override
    público *void *onSensorChanged(*SensorEvent acontecimiento)
      #punt..
      *int *lastTimestamp = Acontecimiento.*timestamp;
      ...
    }

-- 
Recibiste este mensaje porque eres *subscribed al *Google
Grupos "*Android *Developers" grupo.
A correo a este grupo, envía *email a *android-developers@xxxxxxxxxxxxxxxx
A *unsubscribe de este grupo, envía *email a *android-*developers+unsubscribe@xxxxxxxxxxxxxxxx

Puesto que más opciones, visita este grupo en
*http://grupos.*google.*com/Grupo/*android-*developers?*hl=*en
Hello,

You have this:

...
    private SensorEvent lastEvent;
...

@Override
    public void onSensorChanged(SensorEvent event) {
        if (lastEvent == null) {
            lastEvent = event;
            return;
        }
        
        Log.v(TAG, "dT [" + Thread.currentThread().getName() + "]: " + 
(event.timestamp - lastEvent.timestamp));
    }

----------------

The problem is that the "onSensorChanged()" method can be invoked 
concurrently because it is an event listener.
Declare a local variable and copy the value (not just a pointer to the 
object):

@Override
    public void onSensorChanged(SensorEvent event) {
      ...
      int lastTimestamp = event.timestamp;
      ...
    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
android-developers+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
<Anterior por Tema] Tema Actual [Siguiente por Tema>
  • [android-developers] Re: SensorEvent timestamp No siempre actualizar, josean1968 <=