• Tag Archive | "accelometre"

  • Tags: , , ,

    Samsung Moment les caractéristiques techniques du téléphone

    Publié le 08 octobre 2009 par Guy


    Le dernier né de la famille des téléphones sous android  de Samsung le Moment a été annoncé officiellement par l’opérateur Sprint , lire ces billets.

    .

    Par contre ce qui nous manque c’est une liste un peu plus exhaustive des caractéristiques de ce téléphone. Nous avons via le site Android and Me, qui après avoir interrogé plusieurs personnes et regroupé ces informations, un début d’exhaustivité  des caractéristiques de ce nouveau téléphone de Samsung :

    • 800 MHz Samsung S3C6410 CPU
    • 3,2 pouces écran AMOLED (320 x 480 pixels) 16M de couleurs
    • 512 Mo de ROM / 256 Mo de RAM
    • Dimensions: 11.7x 6 x 1.6 cm, poids 158 gramme
    • 2 GB microSD card included / extensible jusqu’à 32 Go
    • Standard Lithium (Li-Ion) de la batterie 1440 mAh (jusqu’à 5,5 heures d’autonomie en continu)
    • Clavier QWERTY qui coulisse à l’horizontale
    • Appareil photo 3,2 mégapixel avec flash et caméscope avec auto-focus
    • WiFi 802.11 b / g, Bluetooth, GPS
    • Accéléromètre et un capteur de proximité
    • Outlook e-mail avec la technologie Direct Push de Microsoft et le support HTML; E-mail (EAS), POP, IMAP
    • Android 1.5

    Petit point négatif de ces caractéristiques la version supportée d’android la 1.5, on aurait pu avoir la 1.6  et éviter une mise à jour.

    Comments (9)

  • Tags: , ,

    Utiliser l’accéléromètre d’android dans ses applications

    Publié le 23 août 2009 par Guy

    Dans ce tuto je vais utiliser l’accéléromètre, pour afficher la position de mon portable dans l’espace. les coordonnées X,Y,Z.

    D’abord mon fichier xml pour afficher le resultat

    ?Download download.txt
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Affiche les coordonnées X,Y,Z"
        />
        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="1">
         <TableRow>
         <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="coord X"
        />
          <EditText  
    	android:id="@+id/textX"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Ingredient"
        android:background="#D4D0C8"
        android:textColor="#000000"
        />
        </TableRow>
        <TableRow>
        <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="      "
        />
        </TableRow>
         <TableRow>
         <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="coord Y"
        />
          <EditText  
    	android:id="@+id/textY"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Ingredient"
        android:background="#D4D0C8"
        android:textColor="#000000"
        />
        </TableRow>
        <TableRow>
        <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="      "
        />
        </TableRow>
         <TableRow>
         <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="coord Z"
        />
          <EditText  
    	android:id="@+id/textZ"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Ingredient"
        android:background="#D4D0C8"
        android:textColor="#000000"
        />
        </TableRow>
     
        </TableLayout>
    </LinearLayout>

    acelometre 200x300 Utiliser laccéléromètre dandroid dans ses applications Android France

    Pour utiliser les capteurs d’android  j’utilise la class SensorManager.

    Dans ma methode onCreate je crée mon objet SensorManager

    ?Download download.txt
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
     public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            // mon objet mSensorManager de type  SensorManager qui prend la main
            mSensorManager = (SensorManager)getSystemService(this.SENSOR_SERVICE); 
          //Sensor. TYPE_ACCELEROMETER défini le type de capteur
         //SensorManager.SENSOR_DELAY_NORMAL le delai  de rafraichissement des informations
            mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), 
            SensorManager.SENSOR_DELAY_NORMAL); 
            //les objet de la fenetre xml
            mTxtViewX = (TextView) findViewById(R.id.textX);
            mTxtViewY = (TextView) findViewById(R.id.textY);
            mTxtViewZ = (TextView) findViewById(R.id.textZ);
     
        }

    je crée une méthode positon qui met à jour les champs TextView de mon Xml.

    ?Download download.txt
    1
    2
    3
    4
    5
    6
    
     public void Position(float iX, float iY, float iZ) 
        { 
        	mTxtViewZ.setText(" "+iZ); 
        	mTxtViewX.setText(" "+iX); 
        	mTxtViewY.setText(" "+iY); 
        }

    Je crée maintenant mon objet SensorEventListener , qui sera l’écouteur des évènements de mon capteur.

    ?Download download.txt
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    private final SensorEventListener mSensorListener = new SensorEventListener() { 
            // action quand le capteur bouge
            public void onSensorChanged(SensorEvent se) 
            { 
                float x = se.values[0]; 
                float y = se.values[1]; 
                float z = se.values[2]; 
                // met à jour la position dans mes TextView
                Position(x, y , z); 
            } 
     
            public void onAccuracyChanged(Sensor sensor, int accuracy) {} 
       };

    Le code complet.

    ?Download download.txt
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    
    package org.accelometre;
     
    import android.app.Activity;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;
    import android.os.Bundle;
    import android.widget.TextView;
     
    public class Accelerometre extends Activity {
    	private SensorManager mSensorManager;
    	private TextView mTxtViewX;
    	private TextView mTxtViewY;
    	private TextView mTxtViewZ;
    	/** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
     
            mSensorManager = (SensorManager)getSystemService(this.SENSOR_SERVICE); 
            mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), 
            SensorManager.SENSOR_DELAY_NORMAL); 
            //mTxtView = new TextView(this);
            mTxtViewX = (TextView) findViewById(R.id.textX);
            mTxtViewY = (TextView) findViewById(R.id.textY);
            mTxtViewZ = (TextView) findViewById(R.id.textZ);
     
        }
     
        public void Position(float iX, float iY, float iZ) 
        { 
        	mTxtViewZ.setText(" "+iZ); 
        	mTxtViewX.setText(" "+iX); 
        	mTxtViewY.setText(" "+iY); 
        }
     
        private final SensorEventListener mSensorListener = new SensorEventListener() { 
     
            public void onSensorChanged(SensorEvent se) 
            { 
                float x = se.values[0]; 
                float y = se.values[1]; 
                float z = se.values[2]; 
                Position(x, y , z); 
            } 
     
            public void onAccuracyChanged(Sensor sensor, int accuracy) {} 
       }; 
     
       @Override 
       protected void onResume() 
       { 
            super.onResume(); 
            mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); 
       } 
     
       @Override 
       protected void onStop() 
       { 
            mSensorManager.unregisterListener(mSensorListener); 
            super.onStop(); 
       } 
     
     
     
     //**********fin de la class*************************   
    }

    Pour tester cette class vous devez disposer d’un téléphone, je ne crois que ça fonctionnera sur l’émulateur.

    Il est temps de mettre à profit les tutoriels d’Android France:
    Passez à la vitesse supérieure et investissez quelques dizaines d’euros pour acquérir les connaissances qui vous feront gagner de l’argent avec vos applications rendez-vous sur notre boutique Android-france pour ces formations en vidéo

    Comments (7)

  • Les Brèves