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 :

Problème développement Android


Sujet :

Android

  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 30
    Par défaut Problème développement Android
    Bonjour à tous !

    Voilà je viens de commencer à développer des applications pour android et j'essaye de gérer la rotation de l'écran, donc je crées sous eclipse un second fichier layout (qui se nome "layout-land") et je fait mes interfaces (portrait et landscape)

    Jusque la tout va bien mais à partir du moment ou je mets le code (dans mon cas celui pour une calculette, histoire de prendre la main avec un projet simple) et que je lance l'émulateur l'application fonctionne parfaitement au format landscape mais des que je passe en portrait il me dit que le processus à cracher et il me dit de forcer l'arrêt...

    Alors est ce qu'il y a un code à mettre pour éviter cela ?

    Merci d'avance,

    Flyer-74

  2. #2
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 169
    Par défaut
    Tu peux nous montrer ton LogCat ?

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 30
    Par défaut
    Oui je veux bien mais c'est quoi !?

  4. #4
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 169
    Par défaut
    Il faut aller dans DDMS ou dans Debug parfois quand ton application est lancée et normalement tu peux voir un onglet LogCat.
    Si ce n'est pas le cas, Windows => Show view => LogCat.

    Le LogCat te permet de voir ce qui se passe sur ton emulateur, les erreurs, les warnings etc...


    Ps : enfin la manip la marche si tu es sur Eclipse.

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 30
    Par défaut
    Voila le LogCat

    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
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    12-18 18:28:11.302: I/ActivityManager(71): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.NavigLio.android.v1/.NavigLio }
    12-18 18:28:11.822: I/ActivityManager(71): Start proc com.NavigLio.android.v1 for activity com.NavigLio.android.v1/.NavigLio: pid=332 uid=10036 gids={}
    12-18 18:28:15.443: D/AndroidRuntime(332): Shutting down VM
    12-18 18:28:15.443: W/dalvikvm(332): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    12-18 18:28:15.713: E/AndroidRuntime(332): FATAL EXCEPTION: main
    12-18 18:28:15.713: E/AndroidRuntime(332): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NavigLio.android.v1/com.NavigLio.android.v1.NavigLio}: java.lang.NullPointerException
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.os.Looper.loop(Looper.java:123)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at java.lang.reflect.Method.invokeNative(Native Method)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at java.lang.reflect.Method.invoke(Method.java:521)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at dalvik.system.NativeStart.main(Native Method)
    12-18 18:28:15.713: E/AndroidRuntime(332): Caused by: java.lang.NullPointerException
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at com.NavigLio.android.v1.NavigLio.onCreate(NavigLio.java:56)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    12-18 18:28:15.713: E/AndroidRuntime(332): 	... 11 more
    12-18 18:28:15.853: W/ActivityManager(71):   Force finishing activity com.NavigLio.android.v1/.NavigLio
    12-18 18:28:16.514: W/ActivityManager(71): Activity pause timeout for HistoryRecord{44e7d3c8 com.NavigLio.android.v1/.NavigLio}
    12-18 18:28:19.663: I/ARMAssembler(71): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x31cfd8:0x31d094] in 110424407 ns
    12-18 18:28:22.295: I/Process(332): Sending signal. PID: 332 SIG: 9
    12-18 18:28:22.543: I/ActivityManager(71): Process com.NavigLio.android.v1 (pid 332) has died.
    12-18 18:28:22.813: W/InputManagerService(71): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44e87d58
    12-18 18:28:23.363: W/ActivityManager(71): Activity pause timeout for HistoryRecord{45082a28 com.android.launcher/com.android.launcher2.Launcher}
    12-18 18:28:25.113: I/WindowManager(71): Setting rotation to 1, animFlags=1
    12-18 18:28:25.213: I/ActivityManager(71): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/1 nav=3/1 orien=2 layout=34 uiMode=17 seq=5}
    12-18 18:28:25.463: I/UsageStats(71): Unexpected resume of com.android.launcher while already resumed in com.android.launcher
    12-18 18:28:28.272: W/ActivityManager(71): Activity destroy timeout for HistoryRecord{44e7d3c8 com.NavigLio.android.v1/.NavigLio}
    12-18 18:28:30.444: W/WindowManager(71): App freeze timeout expired.
    12-18 18:28:30.444: W/WindowManager(71): Force clearing freeze: AppWindowToken{44fbc2c8 token=HistoryRecord{45082a28 com.android.launcher/com.android.launcher2.Launcher}}
    12-18 18:28:33.364: D/dalvikvm(71): GC_EXPLICIT freed 5735 objects / 321688 bytes in 599ms
    12-18 18:28:36.924: D/dalvikvm(189): GC_EXPLICIT freed 3204 objects / 166200 bytes in 1230ms
    12-18 18:28:59.913: I/ActivityManager(71): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.NavigLio.android.v1/.NavigLio }
    12-18 18:29:00.943: I/ActivityManager(71): Start proc com.NavigLio.android.v1 for activity com.NavigLio.android.v1/.NavigLio: pid=340 uid=10036 gids={}
    12-18 18:29:10.083: W/ActivityManager(71): Launch timeout has expired, giving up wake lock!
    12-18 18:29:11.214: I/ActivityManager(71): Displayed activity com.NavigLio.android.v1/.NavigLio: 10514 ms (total 59563 ms)
    12-18 18:29:11.823: I/ARMAssembler(71): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x2e16c8:0x2e17d4] in 5152453 ns
    12-18 18:29:13.173: W/ActivityManager(71): Activity idle timeout for HistoryRecord{44eb42a8 com.NavigLio.android.v1/.NavigLio}
    12-18 18:29:18.562: W/KeyCharacterMap(340): No keyboard for id 0
    12-18 18:29:18.585: W/KeyCharacterMap(340): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
    12-18 18:29:22.123: W/KeyCharacterMap(203): No keyboard for id 0
    12-18 18:29:22.123: W/KeyCharacterMap(203): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
    12-18 18:29:25.083: I/ARMAssembler(71): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x2d5968:0x2d5b30] in 9435708 ns
    12-18 18:29:26.233: D/dalvikvm(203): GC_FOR_MALLOC freed 1578 objects / 217904 bytes in 1548ms
    12-18 18:29:27.033: W/KeyCharacterMap(203): No keyboard for id 0
    12-18 18:29:27.033: W/KeyCharacterMap(203): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
    12-18 18:29:28.997: D/dalvikvm(189): GC_EXPLICIT freed 2777 objects / 155480 bytes in 8903ms
    12-18 18:29:57.183: I/ActivityManager(71): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=6}
    12-18 18:29:57.393: I/UsageStats(71): Unexpected resume of com.NavigLio.android.v1 while already resumed in com.NavigLio.android.v1
    12-18 18:29:57.403: I/WindowManager(71): Setting rotation to 0, animFlags=0
    12-18 18:29:57.473: I/ActivityManager(71): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=7}
    12-18 18:29:57.603: I/UsageStats(71): Unexpected resume of com.NavigLio.android.v1 while already resumed in com.NavigLio.android.v1
    12-18 18:29:58.123: D/AndroidRuntime(340): Shutting down VM
    12-18 18:29:58.123: W/dalvikvm(340): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    12-18 18:29:58.303: E/AndroidRuntime(340): FATAL EXCEPTION: main
    12-18 18:29:58.303: E/AndroidRuntime(340): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NavigLio.android.v1/com.NavigLio.android.v1.NavigLio}: java.lang.NullPointerException
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3815)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.access$2400(ActivityThread.java:125)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2037)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.os.Looper.loop(Looper.java:123)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at java.lang.reflect.Method.invokeNative(Native Method)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at java.lang.reflect.Method.invoke(Method.java:521)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at dalvik.system.NativeStart.main(Native Method)
    12-18 18:29:58.303: E/AndroidRuntime(340): Caused by: java.lang.NullPointerException
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at com.NavigLio.android.v1.NavigLio.onCreate(NavigLio.java:56)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    12-18 18:29:58.303: E/AndroidRuntime(340): 	... 12 more
    12-18 18:29:58.433: W/ActivityManager(71):   Force finishing activity com.NavigLio.android.v1/.NavigLio
    12-18 18:29:59.123: W/ActivityManager(71): Activity pause timeout for HistoryRecord{44eb42a8 com.NavigLio.android.v1/.NavigLio}
    12-18 18:29:59.403: W/WindowManager(71): Window freeze timeout expired.
    12-18 18:29:59.403: W/WindowManager(71): Force clearing orientation change: Window{4501ea88 Sorry! paused=false}
    12-18 18:29:59.413: W/WindowManager(71): Force clearing orientation change: Window{44f7de60 InputMethod paused=false}
    12-18 18:29:59.533: W/InputConnectionWrapper.ICC(203): Timed out waiting on IInputContextCallback
    12-18 18:30:01.853: W/InputConnectionWrapper.ICC(203): Timed out waiting on IInputContextCallback
    12-18 18:30:02.763: W/SurfaceFlinger(71): timeout expired mFreezeDisplay=1, mFreezeCount=0
    12-18 18:30:04.229: W/WindowManager(71): App freeze timeout expired.
    12-18 18:30:04.383: W/WindowManager(71): Window freeze timeout expired.
    12-18 18:30:04.383: W/WindowManager(71): Force clearing orientation change: Window{45117bf8 com.android.internal.service.wallpaper.ImageWallpaper paused=false}
    12-18 18:30:05.173: I/Process(340): Sending signal. PID: 340 SIG: 9
    12-18 18:30:07.136: D/dalvikvm(71): GC_EXPLICIT freed 3408 objects / 200776 bytes in 737ms
    12-18 18:30:08.605: I/ActivityManager(71): Process com.NavigLio.android.v1 (pid 340) has died.
    12-18 18:30:11.726: D/dalvikvm(189): GC_FOR_MALLOC freed 5992 objects / 294880 bytes in 649ms
    12-18 18:30:12.503: W/ActivityManager(71): Activity destroy timeout for HistoryRecord{44eb42a8 com.NavigLio.android.v1/.NavigLio}
    12-18 18:30:13.072: D/dalvikvm(203): GC_FOR_MALLOC freed 10067 objects / 396648 bytes in 525ms
    12-18 18:30:17.643: D/dalvikvm(189): GC_EXPLICIT freed 5733 objects / 301272 bytes in 806ms
    12-18 18:30:57.463: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
    12-18 18:35:06.633: E/ThrottleService(71): Error reading data file
    12-18 18:35:57.493: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
    J’espère que c'est ça ...

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    334
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 334
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Caused by: java.lang.NullPointerException
    at com.NavigLio.android.v1.NavigLio.onCreate(NavigLio.java:56)
    Une NullPointerExeption, ça veut dire que tu essais d'utiliser un objet non créé.
    Regarde donc à la ligne 56 de ta class NavigLio.java
    Les LOGs sont tes amis !
    (par convention, pas de majuscules dans les noms de pacquages)

  7. #7
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 30
    Par défaut
    Citation Envoyé par dawadam Voir le message
    Regarde donc à la ligne 56 de ta class NavigLio.java
    Bah à la ligne 56 j'ai ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    #56 ComAnuler.setOnClickListener(new View.OnClickListener() 
    #57		{
    #58			public void onClick(View view) 
    #59				{
    #60					NomEtape.setText("");
    #61			        Frequence.setText("");
    #62			        AltitudeEtape.setText("");
    #63			        MsaEtape.setText("");
    #64			        RmEtape.setText("");
    #65			        Distance.setText("");
    #66				}
    #67		});
    C'est mon bouton annuler qui vide mes différents champs, ceci s'affiche uniquement lorsqu'on est en landscape et quand on passe en portrait il devrais m'afficher autre choses, en occurrence les valeurs entrées dans mes différents champs ..

  8. #8
    Membre éclairé
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    334
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 334
    Par défaut
    ComAnuler est null

    Android fonctionne à sa manière, par exemple, en cas de changement d'orientation, si ce n'est pas préciser dans le manifest, il recrée l'activité.
    Il faut fouiller dans ce sens.

    Par convention, pas de majuscules au début des noms d'objets.

  9. #9
    Membre confirmé
    Homme Profil pro
    Développeur Web et Mobile
    Inscrit en
    Juin 2010
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeur Web et Mobile

    Informations forums :
    Inscription : Juin 2010
    Messages : 76
    Par défaut
    Me semble t il qu'il faut mettre dans ton manifeste :
    android:launchMode="singleInstance"

  10. #10
    Membre éprouvé
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2009
    Messages : 141
    Par défaut
    Hello,

    Dawadan a raison.

    Android possède un cycle de vie bien particulier des activités.

    Lorsque tu changes ton layout, tes variables perdent la référence des composants car ce
    ne sont plus les même. Il te faut donc les ré-assigner !

    Si tu ajoutes android:configChanges="orientation" dans le manifest tu vas pouvoir gérer cet
    événement. Il va te falloir implémenter la méthode suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    public void onConfigurationChanged(Configuration newConfig)

  11. #11
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 30
    Par défaut
    C'est a dire que je crée une activity onCreate,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    public void onCreate(Bundle savedInstanceState)
    Dans laquelle je déclare tout mes objets et je leurs donnes un écouteur d'évènement à tous (ici il y aura: valider, annuler, informations).

    Puis je crée une nouvelle activity onConfigurationChanged,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    public void onConfigurationChanged(Configuration newConfig)
    dans laquelle je déclare à nouveau tout mes objets ?

    Parce que mon but finale serais que lorsque je suis en landscape j'ai une interface type "édition" et quand je passe en portrait je passe en type "utilisation", je m'explique en landscape il y aurai par exemple deux editText qui me demanderais mon pseudo et un message. Puis lors d'une pression sur le bouton "valider" cela s'enregistre dans une base de donnée et lorsque l'on passe en portrait on vois le nom et le message affiché.

Discussions similaires

  1. Problème de développement Android sur Android Studio
    Par HoussemBk dans le forum Android Studio
    Réponses: 3
    Dernier message: 04/03/2015, 14h52
  2. Réponses: 0
    Dernier message: 11/09/2014, 17h42
  3. Problème pour débuter dans le développement Android
    Par momop72 dans le forum Android
    Réponses: 6
    Dernier message: 05/07/2014, 22h43
  4. Réponses: 13
    Dernier message: 06/08/2010, 17h59

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