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

Composants graphiques Android Discussion :

Intégrer une photo prise de l'APN dans une Imageview


Sujet :

Composants graphiques Android

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Architecte matériel
    Inscrit en
    Mars 2014
    Messages
    35
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Architecte matériel

    Informations forums :
    Inscription : Mars 2014
    Messages : 35
    Points : 27
    Points
    27
    Par défaut Intégrer une photo prise de l'APN dans une Imageview
    Bonjour,
    je réalise une activity qui récupère du texte (destinataire, objet + corps de mail) pour ensuite reformater un email qui peut expédier par un client de messagerie (type gmail).
    Pour la partie texte, l'activity fonctionne sans problème. La ou ca se gâte, c'est pour y intégrer une photo dans ce fameux mail. J’accède à l’ouverture de la fonction APN, prise de photo OK, mais à la validation de cette photo, l'appli plante (au lieu de revenir sur l'activity, m'afficher une vignette de la photo, pour l'envoi mail.

    Donc qui pourrait m'aider sur la partie incrustation de la photo dans mon imagview ?
    Les permissions sont OK dans le manifest,

    Merci

    Activity xml :
    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
    109
    110
    111
    112
    113
    114
    115
    116
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="#000000"
        tools:context=".MainActivity9">
     
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/scrollView4" >
     
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
     
                <TextView
                    android:id="@+id/textViewPhoneNo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="A :"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:background="#000000"
                    android:layout_marginLeft="5dp"
                    android:textColor="#ffffff" />
     
                <EditText
                    android:id="@+id/editTextTo"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:background="#ffffff"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:text="blablabla@gmail.com">
     
                    <requestFocus />
     
                </EditText>
     
                <TextView
                    android:id="@+id/textViewSubject"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Objet :"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:background="#000000"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="5dp"
                    android:textColor="#ffffff" />
     
                <EditText
                    android:id="@+id/editTextSubject"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:background="#ffffff"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp">
                </EditText>
     
                <TextView
                    android:id="@+id/textViewMessage"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Message : "
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:background="#000000"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="5dp"
                    android:textColor="#ffffff" />
     
                <EditText
                    android:id="@+id/editTextMessage"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:gravity="top"
                    android:inputType="textMultiLine"
                    android:lines="5"
                    android:background="#ffffff"
                    android:layout_marginTop="10dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp" />
     
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView5" />
     
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="photo"
                    android:id="@+id/button45"
                    android:layout_marginTop="10dp" />
     
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/ImageView3" />
     
                <Button
                    android:id="@+id/buttonSend"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Envoyer" />
     
            </LinearLayout>
        </ScrollView>
     
    </LinearLayout>

    et pour l'activity java :
    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
    package essai.app;
     
     
    import android.app.Activity;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.drawable.BitmapDrawable;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.view.View.OnClickListener;
    import android.widget.ImageView;
    import android.widget.Toast;
     
     
    public class MainActivity9 extends Activity {
     
     
            Button buttonSend;
            Button BT;
            EditText textTo;
            EditText textSubject;
            EditText textMessage;
            ImageView img;
     
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main9);
     
                buttonSend = (Button) findViewById(R.id.buttonSend);
                BT = ((Button) findViewById(R.id.button45));
                textTo = (EditText) findViewById(R.id.editTextTo);
                textSubject = (EditText) findViewById(R.id.editTextSubject);
                textMessage = (EditText) findViewById(R.id.editTextMessage);
                img = (ImageView) findViewById(R.id.imageView3);
     
                BT.setOnClickListener(new OnClickListener() {
     
                   @Override
                   public void onClick(View v) {
     
                       Toast.makeText(MainActivity9.this, "Activation de l'appareil photo", Toast.LENGTH_SHORT).show();
                       Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                       startActivityForResult(intent, 0);
                   }
                });
     
                buttonSend.setOnClickListener(new OnClickListener() {
     
                    @Override
                    public void onClick(View v) {
     
                        textTo.setText("blablabla@gmail.com");
                        String to = textTo.getText().toString();
                        String subject = textSubject.getText().toString();
                        String message = textMessage.getText().toString();
     
                        Intent email = new Intent(Intent.ACTION_SEND);
                        email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
                        email.putExtra(Intent.EXTRA_SUBJECT, subject);
                        email.putExtra(Intent.EXTRA_TEXT, message);
     
                        //need this to prompts email client only
                        email.setType("message/rfc822");
     
                        startActivity(Intent.createChooser(email, "Choix du service MAIL :"));
     
                    }
                });
            }
     
            @Override
            protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            //TODO Auto-generated method stub
            super.onActivityResult(requestCode, resultCode, data);
            Bitmap bit= (Bitmap) data.getExtras().get("data");
            img.setImageBitmap(bit);
            }
     
    }

  2. #2
    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
    Si ton application plante, tu as une erreur dans le LogCat. Peux-tu nous fournir la stacktrace de l'exception s'il te plaît ?
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

Discussions similaires

  1. [MySQL] recuperer une valeur dans une liste deroulante pour l'utiliser dans une seconde liste
    Par tortue_22 dans le forum PHP & Base de données
    Réponses: 12
    Dernier message: 12/05/2010, 11h50
  2. Réponses: 5
    Dernier message: 04/12/2008, 15h58
  3. Réponses: 4
    Dernier message: 04/07/2008, 10h34
  4. Réponses: 1
    Dernier message: 22/06/2008, 22h47
  5. Réponses: 2
    Dernier message: 05/10/2007, 23h49

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