IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

erreur lors de la demarrage


Sujet :

Android

  1. #1
    Candidat au Club
    Inscrit en
    Février 2013
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2013
    Messages : 23
    Points : 3
    Points
    3
    Par défaut erreur lors de la demarrage
    pourquoi ce code ne fonctionne pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    package com.example.a28012014;
     
    import java.util.HashMap;
    import java.util.Iterator;
     
    import android.hardware.usb.UsbDevice;
    import android.hardware.usb.UsbManager;
    import android.os.Build;
    import android.os.Bundle;
    import android.annotation.SuppressLint;
    import android.annotation.TargetApi;
    import android.app.Activity;
    import android.util.Log;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
     
    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    @SuppressLint("NewApi")
    public class MainActivity extends Activity {
     
    	private String LOG_TAG;
    	TextView heure = null;
    	Button Button01= null;
     
     
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    	}
     
    	@Override
    	protected void onStart() {
    		super.onStart();
    		Button01 = (Button)findViewById(R.id.button01);
     
    		Button01.setOnClickListener(new View.OnClickListener()
    		{
     
    			public void onClick(View arg0) {
     
    			try {
    				Log.i(LOG_TAG,"USB HOST");
    				UsbManager usbManager=(UsbManager)getSystemService(USB_SERVICE);
    				HashMap<String,UsbDevice> deviceList=usbManager.getDeviceList();
    				Iterator<UsbDevice> deviceIterator=deviceList.values().iterator();
     
    					while(deviceIterator.hasNext()){
    						UsbDevice device=deviceIterator.next();
    						heure=  (TextView) findViewById(R.id.heure);
    						heure.setText(Log.i(LOG_TAG, "MOdel"+device.getDeviceName())+
    						Log.i(LOG_TAG, "id"+device.getDeviceId())+
    						Log.i(LOG_TAG, "Class"+device.getDeviceClass())+
    						Log.i(LOG_TAG, "Protocol"+device.getDeviceProtocol())+
    						Log.i(LOG_TAG, "Protocol"+device.getDeviceProtocol())+
    						Log.i(LOG_TAG, "VendorId"+device.getVendorId())+
    						Log.i(LOG_TAG, "ProductId"+device.getProductId())+
    						Log.i(LOG_TAG, "---------------------------------"));
    						heure=  (TextView) findViewById(R.id.heure);
    						heure.setText("error");
    					}
    				}
    			catch(Exception e){
    				Log.e(LOG_TAG, e.getMessage());
     
     
     
     
     
    			}
     
    			}
     
     
     
    		});
     
    	}
     
     
     
    	@Override
    	public boolean onCreateOptionsMenu(Menu menu) {
    		// Inflate the menu; this adds items to the action bar if it is present.
    		getMenuInflater().inflate(R.menu.main, menu);
    		return true;
    	}
     
    }
    activity main
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
     
     
    <TextView
            android:id="@+id/heure"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             />
     
        <Button
            android:id="@+id/button01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/button01"
            android:layout_marginTop="55dp"
            android:layout_toRightOf="@+id/button01"
            android:text="affiche" />
    </RelativeLayout>
    android manifest
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.a28012014"
        android:versionCode="1"
        android:versionName="1.0" >
     
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="18" />
     
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.a28012014.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
     
     
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
                <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
     />
            </activity>
        </application>
     
    </manifest>

  2. #2
    Membre confirmé Avatar de ruscov
    Homme Profil pro
    Architecte de système d'information
    Inscrit en
    Mars 2007
    Messages
    347
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Belgique

    Informations professionnelles :
    Activité : Architecte de système d'information

    Informations forums :
    Inscription : Mars 2007
    Messages : 347
    Points : 500
    Points
    500
    Par défaut
    Surement parce qu'il y a une exception qui sort que tu ne nous as pas donné...

  3. #3
    Candidat au Club
    Inscrit en
    Février 2013
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2013
    Messages : 23
    Points : 3
    Points
    3
    Par défaut
    donc on crée une Class exception

  4. #4
    Membre averti Avatar de toutgrego
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2013
    Messages
    217
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2013
    Messages : 217
    Points : 350
    Points
    350
    Par défaut
    Citation Envoyé par alaa1993 Voir le message
    ce code ne fonctionne pas
    C'est à dire ? Il se passe quoi ?

  5. #5
    Candidat au Club
    Inscrit en
    Février 2013
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2013
    Messages : 23
    Points : 3
    Points
    3
    Par défaut
    il affiche the application has stopped unexpectedly

  6. #6
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Dans ce cas, tu as une erreur dans le LogCat, et comme l'a bien dit ruscov, il est nécessaire de nous fournir l'exception complète.

  7. #7
    Candidat au Club
    Inscrit en
    Février 2013
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2013
    Messages : 23
    Points : 3
    Points
    3
    Par défaut
    comment faire ?

  8. #8
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Il suffit simplement que tu cherches l'onglet ou la vue "LogCat" de ton IDE. Une fois localisée, ouvre-là, tu devrais voir pleins de lignes défiler à un rythme plus ou moins soutenus.

    Une fois que tu l'as ouvert, lance ton application (rouvre l'onglet ensuite au besoin), navigue jusqu'au crash et copie/colle l'erreur qui est apparu dans le LogCat.

    Sans ça, c'est difficile de t'aiguiller, sachant qu'ici, peu de contributeurs prendront le temps de monter un projet de A à Z pour tester ton code.

    EDIT : Un tuto : http://vogella.developpez.com/tutori...gging-Android/

Discussions similaires

  1. [Liferay] Erreur lors du demarrage de Tomcat
    Par soveste dans le forum Portails
    Réponses: 1
    Dernier message: 20/11/2009, 20h20
  2. erreur lors du demarrage du contexte
    Par gloglo dans le forum Tomcat et TomEE
    Réponses: 18
    Dernier message: 23/05/2007, 10h22
  3. erreur lors de demarrage de jboss?
    Par chakala dans le forum Wildfly/JBoss
    Réponses: 3
    Dernier message: 21/04/2007, 07h20
  4. message d'erreur lors du Démarrage
    Par abdallahi dans le forum Windows XP
    Réponses: 2
    Dernier message: 14/11/2006, 14h20
  5. erreur lors de demarrage de win98
    Par StyleXP dans le forum Windows 2000/Me/98/95
    Réponses: 5
    Dernier message: 23/01/2006, 10h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo