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 :

Génération d'un code barre


Sujet :

Android

  1. #1
    Membre du Club
    Inscrit en
    Mars 2011
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 62
    Points : 55
    Points
    55
    Par défaut Génération d'un code barre
    Bonjour tout le monde,

    J'ai développé un exemple comment scanner un code barre en android avec la bibliothèque Zxing mais le problème c'est que je n'arrive pas a générer ce numéro du code barre dans une Textview ou imageview

    Quelqu'un aurait une idée , le date de fin du projet approche.

    Merci

  2. #2
    Expert éminent

    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
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    c'est que je n'arrive pas a générer ce numéro du code barre dans une Textview ou imageview
    Tu n'arrives pas à récupérer ton code depuis le scan, ou tu n'arrives pas à le traiter ?
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  3. #3
    Membre du Club
    Inscrit en
    Mars 2011
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 62
    Points : 55
    Points
    55
    Par défaut
    Citation Envoyé par Feanorin Voir le message
    Bonjour,



    Tu n'arrives pas à récupérer ton code depuis le scan, ou tu n'arrives pas à le traiter ?
    Bonjour,

    J'arrive a scanner le code mais le problème c'est de traiter.
    j'arrive avec ce code a le scanner et connaitre le format du code a barre mais

    j'arrive pas a générer ce code dans un Textview ou Imageview c'est ça le problème.

    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
    public class AndroidScanner extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
     
            try {
                Button scanner = (Button)findViewById(R.id.scanner);
                scanner.setOnClickListener(new OnClickListener() {
     
                    public void onClick(View v) {
                        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
                        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
                        startActivityForResult(intent, 0);
                    }
     
                });
     
                Button scanner2 = (Button)findViewById(R.id.scanner2);
                scanner2.setOnClickListener(new OnClickListener() {
     
                    public void onClick(View v) {
                        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
                        intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
                        startActivityForResult(intent, 0);
                    }
     
                });
     
            } catch (ActivityNotFoundException anfe) {
                Log.e("onCreate", "Scanner Not Found", anfe);
            }
     
        }
     
        public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            if (requestCode == 0) {
                if (resultCode == RESULT_OK) {
                    String contents = intent.getStringExtra("SCAN_RESULT");
                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
                    // Handle successful scan
                    Toast toast = Toast.makeText(this, "Content:" + contents + " Format:" + format , Toast.LENGTH_LONG);
                    toast.setGravity(Gravity.TOP, 25, 400);
                    toast.show();
                } else if (resultCode == RESULT_CANCELED) {
                    // Handle cancel
                    Toast toast = Toast.makeText(this, "Scan was Cancelled!", Toast.LENGTH_LONG);
                    toast.setGravity(Gravity.TOP, 25, 400);
                    toast.show();
     
                }
            }
        }
     
    }

  4. #4
    Expert éminent

    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
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    Pour récupérer le retour du scan :

    Initialise l'Intent

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    IntentIntegrator integrator = new IntentIntegrator(yourActivity);
    integrator.initiateScan();
    Sur le retour de ton activity récupères l'information depuis cet intent

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
      if (scanResult != null) {
        // handle scan result
        // si tu veux faire une recherchge par exemple
              String s = "http://www.google.com/search?q=";
                s += scanResult.getContents();
        // sinon
         TaTextViex.SetText(scanResult.getContents());
      }
      // else continue with any other code you need in the method
      ...
    }
    Voici le lien :
    http://code.google.com/p/zxing/wiki/ScanningViaIntent
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  5. #5
    Membre du Club
    Inscrit en
    Mars 2011
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 62
    Points : 55
    Points
    55
    Par défaut
    Citation Envoyé par Feanorin Voir le message
    Bonjour,

    Pour récupérer le retour du scan :

    Initialise l'Intent

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    IntentIntegrator integrator = new IntentIntegrator(yourActivity);
    integrator.initiateScan();
    Sur le retour de ton activity récupères l'information depuis cet intent

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
      if (scanResult != null) {
        // handle scan result
        // si tu veux faire une recherchge par exemple
              String s = "http://www.google.com/search?q=";
                s += scanResult.getContents();
        // sinon
         TaTextViex.SetText(scanResult.getContents());
      }
      // else continue with any other code you need in the method
      ...
    }
    Voici le lien :
    http://code.google.com/p/zxing/wiki/ScanningViaIntent
    Merci bien , mais j'ai besoin de générer le code bar, c'est à dire, le numéro du code bar (texte) doit être transformer en code bar (image).
    C'est cela mon besoin

  6. #6
    Expert éminent

    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
    Points : 9 149
    Points
    9 149
    Par défaut
    :/

    Voici un exemple sur l'utilisation du zxing:
    http://code.google.com/p/zxing/sourc...tActivity.java

    Voici ce que tu dois mettre dans l'intent à éxécuter.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
    intent.putExtra("ENCODE_TYPE", "TEXT");
    intent.putExtra("ENCODE_FORMAT", "UPC_A"); // regardes quel format tu as besoin
    intent.putExtra("ENCODE_DATA", tadata.ToString());
     
    startActivity(intent);
    Voici les informations disponible depuis l'intent
    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
        /**
         * The data to encode. Use {@link android.content.Intent#putExtra(String, String)} or
         * {@link android.content.Intent#putExtra(String, android.os.Bundle)}, 
         * depending on the type and format specified. Non-QR Code formats should
         * just use a String here. For QR Code, see Contents for details.
         */
        public static final String DATA = "ENCODE_DATA";
     
        /**
         * The type of data being supplied if the format is QR Code. Use
         * {@link android.content.Intent#putExtra(String, String)} with one of {@link Contents.Type}.
         */
        public static final String TYPE = "ENCODE_TYPE";
     
        /**
         * The barcode format to be displayed. If this isn't specified or is blank,
         * it defaults to QR Code. Use {@link android.content.Intent#putExtra(String, String)}, where
         * format is one of {@link com.google.zxing.BarcodeFormat}.
         */
        public static final String FORMAT = "ENCODE_FORMAT";
     
        /**
         * Normally the contents of the barcode are displayed to the user in a TextView. Setting this
         * boolean to false will hide that TextView, showing only the encode barcode.
         */
        public static final String SHOW_CONTENTS = "ENCODE_SHOW_CONTENTS";
    le lien :
    http://code.google.com/p/zxing/sourc...d/Intents.java

    Les différents format disponible :
    http://code.google.com/p/zxing/sourc...at.java?r=1949
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  7. #7
    Membre du Club
    Inscrit en
    Mars 2011
    Messages
    62
    Détails du profil
    Informations forums :
    Inscription : Mars 2011
    Messages : 62
    Points : 55
    Points
    55
    Par défaut
    Citation Envoyé par Feanorin Voir le message
    :/

    Voici un exemple sur l'utilisation du zxing:
    http://code.google.com/p/zxing/sourc...tActivity.java

    Voici ce que tu dois mettre dans l'intent à éxécuter.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
    intent.putExtra("ENCODE_TYPE", "TEXT");
    intent.putExtra("ENCODE_FORMAT", "UPC_A"); // regardes quel format tu as besoin
    intent.putExtra("ENCODE_DATA", tadata.ToString());
     
    startActivity(intent);
    Voici les informations disponible depuis l'intent
    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
        /**
         * The data to encode. Use {@link android.content.Intent#putExtra(String, String)} or
         * {@link android.content.Intent#putExtra(String, android.os.Bundle)}, 
         * depending on the type and format specified. Non-QR Code formats should
         * just use a String here. For QR Code, see Contents for details.
         */
        public static final String DATA = "ENCODE_DATA";
     
        /**
         * The type of data being supplied if the format is QR Code. Use
         * {@link android.content.Intent#putExtra(String, String)} with one of {@link Contents.Type}.
         */
        public static final String TYPE = "ENCODE_TYPE";
     
        /**
         * The barcode format to be displayed. If this isn't specified or is blank,
         * it defaults to QR Code. Use {@link android.content.Intent#putExtra(String, String)}, where
         * format is one of {@link com.google.zxing.BarcodeFormat}.
         */
        public static final String FORMAT = "ENCODE_FORMAT";
     
        /**
         * Normally the contents of the barcode are displayed to the user in a TextView. Setting this
         * boolean to false will hide that TextView, showing only the encode barcode.
         */
        public static final String SHOW_CONTENTS = "ENCODE_SHOW_CONTENTS";
    le lien :
    http://code.google.com/p/zxing/sourc...d/Intents.java

    Les différents format disponible :
    http://code.google.com/p/zxing/sourc...at.java?r=1949
    a quoi sert
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    intent.putExtra("ENCODE_DATA", tadata.ToString());
    tadata ????

  8. #8
    Expert éminent

    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
    Points : 9 149
    Points
    9 149
    Par défaut
    Si tu préfères :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    intent.putExtra("ENCODE_DATA", "123456789");
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

Discussions similaires

  1. [iText] [BarcodeEAN] génération d'un code barre
    Par ianto dans le forum Documents
    Réponses: 1
    Dernier message: 02/09/2010, 17h18
  2. Génération de code barre
    Par gids01 dans le forum Jasper
    Réponses: 4
    Dernier message: 03/06/2008, 11h05
  3. génération de code barre
    Par mateuil dans le forum Windows Forms
    Réponses: 9
    Dernier message: 16/01/2008, 15h49
  4. Génération de code barre
    Par kprime1 dans le forum ASP.NET
    Réponses: 1
    Dernier message: 14/04/2007, 03h20

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