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 :

Gestion des évènements


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre chevronné Avatar de ma5t3r
    Homme Profil pro
    Développeur freelance
    Inscrit en
    Mai 2015
    Messages
    320
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 320
    Par défaut Gestion des évènements
    Bonjour,
    J'essaie désespérément de créer et intercepter un événement dans une app android mais c'est sans succès malgré les recherches effectuées.
    Avec plus ou moins de complexité, les exemples que j'ai pu trouver ne sont pas suffisamment simplistes pour bien comprendre le mécanisme.
    Développeur VB.net habituellement, j'ai plutôt l'habitude de créer des événements de façon intuitive sans me poser de questions.
    Je débute en Java et ne suis pas encore très à l'aise avec la philosophie de ce langage.

    Pour en revenir à mon souci, j'ai 2 classes :
    Une classe MyCustomObject qui est censée faire remonter les events
    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
    public class MyCustomObject {
        public interface MyCustomObjectListener {
            void onStart(int maxValue);
            void onLoop(int i);
            void onEnd();
        }
        private MyCustomObjectListener listener;
        public MyCustomObject() {
            this.listener = null;
            loadDatas();
        }
        public void setCustomObjectListener(MyCustomObjectListener listener) {
            this.listener = listener;
        }
        public void loadDatas() {
            try {
                if (listener != null) listener.onStart(1000);
                for (int i = 0; i < 1000; i++) {
                    if (listener != null) listener.onLoop(i);
                }
                if (listener != null) listener.onEnd();
     
            } catch (Exception e) {
                Log.i("EWWO", e.getMessage());
            }
        }
    }
    Et mon Activity qui instancie cette classe qui fait appel à la methode LoadData qui théoriquement, devrait déclencher le mécanisme.
    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
    public class Activity_Test extends Activity {
     
        TextView lblResult;
        Button btTest;
     
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_test);
     
            lblResult = (TextView) findViewById(R.id.lblResult);
            btTest = (Button) findViewById(R.id.btTest);
     
     
            btTest.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        lblResult.setText("");
                        MyCustomObject object = new MyCustomObject();
                        object.setCustomObjectListener(new MyCustomObject.MyCustomObjectListener() {
                            @Override
                            public void onStart(int maxValue) {
                                lblResult.setText("maxValue = " + maxValue);
                            }
     
                            @Override
                            public void onLoop(int i) {
                                lblResult.setText("En traitement " + i);
                            }
     
                            @Override
                            public void onEnd() {
                                lblResult.setText("Terminé");
                            }
                        });
                    } catch (Exception e) {
                        Log.i("EWOO", e.getMessage());
                    }
     
                }
            });
     
        }
     
    }
    Je ne crois pas pouvoir faire plus simple au niveau du code.
    Impossible d'accéder aux événements lors du debug.

    Merci de votre aide

  2. #2
    Expert confirmé

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Par défaut
    Ben vu le code ca devait bien appelé ta classe anonyme.

    TU as quoi comme souci quand tu débogues ?

  3. #3
    Membre chevronné Avatar de ma5t3r
    Homme Profil pro
    Développeur freelance
    Inscrit en
    Mai 2015
    Messages
    320
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 320
    Par défaut
    Bonjour et merci de t’intéresser à mon problème.
    J'ai mis des points d'arret sur les events et impossible d'y accéder.

  4. #4
    Expert confirmé

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Par défaut
    Tu as quoi dans ton logcat ?

    Tu rentes dans le click de ton bouton déjà ?

  5. #5
    Membre chevronné Avatar de ma5t3r
    Homme Profil pro
    Développeur freelance
    Inscrit en
    Mai 2015
    Messages
    320
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2015
    Messages : 320
    Par défaut
    Je rentre bien sur le setOnClickListener du bouton
    J'ai mis un try/catch sur la totalité du traitement comme tu as pu le voir dans la méthode plus haut mais je ne stoppe pas sur le point d'arrêt du catch.

    le logCat
    Oops, à quoi ca peut bien correspondre ?

    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
    102
    103
    104
    105
    106
    107
    108
    05-19 10:23:55.829     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.829     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:55.897     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.897     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:55.913     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.913     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.055     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.055     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.164     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.164     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.183     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.184     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.237     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.237     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.241     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.241     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.263     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.263     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.329     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.329     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.374     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.374     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.378     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.378     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.400     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.400     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.406     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.406     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.761     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.761     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.827     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.827     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.828     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.828     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.940     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.941     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:55.829     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.829     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:55.897     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.897     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:55.913     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:55.913     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.055     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.055     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.164     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.164     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.183     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.184     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.237     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.237     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.241     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.241     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.263     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.263     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.329     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.329     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.374     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.374     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.378     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.378     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.400     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.400     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.406     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000101a
    05-19 10:23:56.406     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000101a
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.415     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.423     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.428     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.476     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.623     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.631     940-1447/? E/OMXNodeInstance﹕ OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    05-19 10:23:56.761     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.761     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.827     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.827     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.828     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.828     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e
    05-19 10:23:56.940     940-1447/? E/OMXNodeInstance﹕ getParameter(100663311) ERROR: 0x8000100e
    05-19 10:23:56.941     940-1447/? E/OMXNodeInstance﹕ getParameter(100663297) ERROR: 0x8000100e

  6. #6
    Expert confirmé

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Par défaut
    Normalement il me faudrait le logcat filtré que sur le nom de package de ton application, c'est en gros la console d'écoute des messages systèmes. Tous tes logs seront intercepté par le logcat.

    Je ne vois pas quoi pourrais poser problème tu perds le debug a quel endroit ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XML] [EXPAT] xml_parse et la gestion des événements...
    Par Herode dans le forum Bibliothèques et frameworks
    Réponses: 2
    Dernier message: 05/02/2006, 20h59
  2. Gestion des évènements Netscape 7.0
    Par RATHQUEBER dans le forum Autres langages pour le Web
    Réponses: 6
    Dernier message: 19/12/2005, 16h26
  3. Problème avec la gestion des événements
    Par CynO dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 17/10/2005, 10h07
  4. [JTable] gestion des événements
    Par soulhouf dans le forum Composants
    Réponses: 4
    Dernier message: 19/08/2005, 13h21
  5. Gestion des évènements lors d'un clique sur une image.
    Par yoghisan dans le forum Débuter
    Réponses: 7
    Dernier message: 23/06/2005, 19h04

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