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 intégration adresse mail du destinataire


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Par défaut Problème intégration adresse mail du destinataire
    Bonsoir,
    S'il vous plait maintenant j'ai un problème avec l'intégration de l'email dans la destination de l'application GMAIL. est ce que c'est faux pour la récupération d'écrire comme ça? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    public boolean onContextItemSelected(MenuItem item) {
    		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    		switch(item.getItemId()){
    case 400:
    		 Intent sendMailIntent = new Intent(Intent.ACTION_SEND); 
    			 sendMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{ email }); 
    		        sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, "Sujet du mail"); 
    		        sendMailIntent.putExtra(Intent.EXTRA_TEXT, "Ici le contenu du message\nMultiligne bien sur ;)\n\n"); 
    		        sendMailIntent.setType("message/rfc822"); 
    		        startActivity(Intent.createChooser(sendMailIntent, "Choose an Email client :"));
    break;
    }
    J'ai récupéré l'email dans OnListItemClick et testé avec un toast et ça me retourne l'email:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    email = cursor.getString(cursor.getColumnIndex("email"));

  2. #2
    Membre chevronné
    Homme Profil pro
    Ed Nat
    Inscrit en
    Janvier 2013
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ed Nat
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2013
    Messages : 325
    Par défaut
    Bonsoir,
    à priori, ça a l'air correct...
    Ça ne fonctionne pas ?

  3. #3
    Membre éclairé Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Par défaut
    non en principe j'aurai dans le champ destination le contenu de la variable String email, alors que moi je n'ai rien. Cependant lorsque j'essaye en intégrant directement un email ça marche;càd comme ça:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     sendMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{ "adresse@ghhjj" });
    je ne comprends pas ou est le problème! le toast fonctionne, la variable email contient l'adresse email mais elle ne s'affiche pas dans le champ

  4. #4
    Membre chevronné
    Homme Profil pro
    Ed Nat
    Inscrit en
    Janvier 2013
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ed Nat
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2013
    Messages : 325
    Par défaut
    Bizarre bizarre...
    Remet tout le code de ton activité afin que tout le monde puisse suivre...
    et pour qu'aucun détail ne nous échappe

  5. #5
    Membre éclairé Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Par défaut
    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
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    public class ResultResearch extends ListActivity implements OnClickListener {
     
     
    	FormationBDD formationBdd;
    	Formation liste;
    	String tel;
    	double latitude;
    	double longitude;
    	long _id;
    	String email;
     
    	public final static String ID = "com.guideformation.main.ID";
     
    	@Override
    	  public void onCreate(Bundle savedInstanceState) {
    	    super.onCreate(savedInstanceState);
    	    setContentView(R.layout.resultat_list);
    	 // On récupère l'intent qui a lancé cette activité
    	    Intent i = getIntent();
    	    String ville = i.getStringExtra(RechercheActivity.VILLE);
    	    String catégorie = i.getStringExtra(RechercheActivity.CATEGORIE);
    	    formationBdd = new FormationBDD(this);
    	    formationBdd.open();
    	 //   liste = formationBdd.getFormation(ville, catégorie); 
    		//    if (liste == null)
    		 //       Toast.makeText(Main3.this, "liste de formation vide ", Toast.LENGTH_LONG).show();
    		   //     else
    		        	DataBind(ville, catégorie);
    		        	registerForContextMenu(getListView());
    	}
     
        @Override // Création du menu principal
        public boolean onCreateOptionsMenu(Menu menu) {    	
        	menu.add(0,100,0,"Tout effacer");
        	return true;
        }
     
        @Override // Selection d'un item du menu
        public boolean onOptionsItemSelected(MenuItem item) {
        	switch(item.getItemId()){
        	case 100: 
        		//db.Truncate();
        		//DataBind();
        		break;    	
        	}
        	return true;
        }
     
    	@Override // Selection d'un item de la liste
    	protected void onListItemClick(ListView l, View v, int position, long id) {
    		Cursor cursor = (Cursor)l.getAdapter().getItem(position);
    		tel  = cursor.getString(cursor.getColumnIndex("tel"));
    		latitude = cursor.getDouble(cursor.getColumnIndex("latitude"));
    		latitude = cursor.getDouble(cursor.getColumnIndex("longitude"));
    		_id = cursor.getLong(cursor.getColumnIndex("_id"));
    		email = cursor.getString(cursor.getColumnIndex("email"));
    		Toast.makeText(ResultResearch.this, email, Toast.LENGTH_LONG).show();
    		v.showContextMenu();
     
    	}
     
    	@Override // Creation du menu contextuel
    	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    		super.onCreateContextMenu(menu, v, menuInfo);
    		menu.setHeaderTitle("Action");
    		menu.add(0,100,0,"Call");
    		menu.add(0,200,1,"More details");
    		menu.add(0, 300, 3, "Localisation");
    		menu.add(0,400,2,"send mail");
    		menu.add(0,500,4,"add comment");
    	}
     
    	@Override // Selection d'un item du menu contextuel
    	public boolean onContextItemSelected(MenuItem item) {
    		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    		switch(item.getItemId()){
    		// if "call" selected
    		case 100:
     
    		Intent appel = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+ tel));
    		startActivity(appel);
    			break;
    			//if "More details" selected
    		case 200:
    			Intent result = new Intent(ResultResearch.this, DetailCenter.class);
    			result.putExtra(ID, _id);
    			startActivity(result);	
     
    			break;
    			//if "Localisation" selected
    		case 300:
    			break;
    			// if "send mail" selected
    		case 400:
    			 Intent sendMailIntent = new Intent(Intent.ACTION_SEND); 
    			 sendMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{ email }); 
    		        sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, "Sujet du mail"); 
    		        sendMailIntent.putExtra(Intent.EXTRA_TEXT, "Ici le contenu du message\nMultiligne bien sur ;)\n\n"); 
    		        sendMailIntent.setType("message/rfc822"); 
    		        startActivity(Intent.createChooser(sendMailIntent, "Choose an Email client :")); 
    			break;
    		case 500:
    			Intent add = new Intent(ResultResearch.this, CommentActivity.class);
    			add.putExtra(ID, _id);
    			startActivity(add);	
    		}
    		return true;
    	}
     
        @Override
        protected void onDestroy() {
        //	db.close();
        	super.onDestroy();
        }
     
     
    	 public void DataBind(String ville, String catégorie){
     
    	    	Cursor c = formationBdd.recupererChoixFormations(ville, catégorie);
    	    	startManagingCursor(c);
    	    	SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
    	    	    	R.layout.list1,c,new String[]{"libellé","adresse","tel"},
    	    	    	new int[]{R.id.textLibellé,R.id.TextAdresse,R.id.TextTel});
    	    	    	setListAdapter(adapter);
    	 }
     
    	@Override
    	public void onClick(View v) {
    		// TODO Auto-generated method stub
     
    	}
    }
    resultat_list.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
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
     
     
         <ListView
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:id="@android:id/list"
        />
     
    </LinearLayout>
    list1.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
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
     
    	<TextView 
    	android:layout_width="fill_parent"
    	android:layout_height="fill_parent"
    	android:textStyle="bold"
    	android:id="@+id/textLibellé"
    	/>	
    	<TextView 
    	 android:layout_width="fill_parent"
    	 android:layout_height="fill_parent"
    	android:id="@+id/TextAdresse"
    	 android:text="adresse: "
     
    	/>
     
    	<TextView 
    	 android:layout_width="fill_parent"
    	 android:layout_height="fill_parent"
    	android:id="@+id/TextTel"
    	  android:text="Tel: "
     
    	/>
     
    </LinearLayout>

  6. #6
    Membre chevronné
    Homme Profil pro
    Ed Nat
    Inscrit en
    Janvier 2013
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ed Nat
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2013
    Messages : 325
    Par défaut
    je ne vois pas...
    Remet un toast de l'email avant la ligne d'affectation du destinataire, juste pour voir si email est bien affecté :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    Toast.makeText(ResultResearch.this, email, Toast.LENGTH_LONG).show();
    sendMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{ email });
    et dit moi ce que ça donne

  7. #7
    Membre éclairé Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Par défaut
    ça affiche un toast vide

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 20/06/2014, 10h09
  2. Bouton pour renseigner l'adresse mail du destinataire
    Par kyushin dans le forum VBA Outlook
    Réponses: 7
    Dernier message: 16/10/2012, 13h44
  3. Récupérer l'adresse mail des destinataires d'un message
    Par PaulR dans le forum VBA Outlook
    Réponses: 3
    Dernier message: 02/09/2011, 11h00
  4. Réponses: 1
    Dernier message: 19/05/2010, 12h27
  5. Réponses: 21
    Dernier message: 19/11/2008, 11h07

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