2012-02-15 15 views
7

Sono un principiante per Android. Devo sapere se c'è intenzione di aprire la finestra Crea messaggio. Ho provato con questo codice -Android: Intento messaggio

Intent i = new Intent(Intent.ACTION_SEND); 
i.setType("text/plain"); 

Ma, solleva, Gmail, Email & Message ho bisogno di alzare unico messaggio. Nella mia applicazione devo integrarlo quando preme il pulsante. Qualcuno può saperlo? Guidami.

risposta

7

Si può solo nel file XML aggiungere

android:onClick = "onClick" 

e in attività:

//main buttons listener 
public void onClick(View view) 
{ 
    switch (view.getId()) 
    { 
      case R.id.sms: 
      Intent intentsms = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + "")); 
      intentsms.putExtra("sms_body", "Test text..."); 
      startActivity(intentsms); 
      break; 
    } 
} 
+0

Sì, questo funziona bene. Grazie. –

+0

Se puoi solo risponderti :) – goodm

+1

Non posso accettare ora. Mi sta dicendo "Puoi accettare questa risposta entro 3 minuti –

0

Credo che questo dovrebbe funzionare:

i.addCategory(Intent.CATEGORY_DEFAULT); 
i.setType("vnd.android-dir/mms-sms"); 
+0

Grazie per le tue preziose informazioni –

1

questo vi aiuterà a:

Intent sendIntent = new Intent(Intent.ACTION_VIEW); 
sendIntent.setType("vnd.android-dir/mms-sms"); 
startActivity(sendIntent); 
+0

Grazie per le tue preziose informazioni. –

4

Prova questa:

Intent i = new Intent(Intent.ACTION_SEND); 
i.setType("text/plain"); 
i.putExtra(Intent.EXTRA_EMAIL , new String[] { "[email protected]" }); 
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email"); 
i.putExtra(Intent.EXTRA_TEXT , "body of email"); 
try { 
    startActivity(Intent.createChooser(i, "Send mail...")); 
} catch (android.content.ActivityNotFoundException ex) { 
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); 
} 
1

Usa proprio come questo per tutte le applicazioni accetterà questo intento

case R.id.action_shareapp: 
      Intent send = new Intent(Intent.ACTION_SEND); 
      send.setType("text/plain"); 
      send.putExtra(
        Intent.EXTRA_TEXT, 
        "Checkout this coool App follow this link. https://play.google.com/store/apps/details?id=com.picknget.android"); 
      startActivity(Intent.createChooser(send, "Share with")); 
      break; 
Problemi correlati