2012-02-15 11 views
7

Soy un principiante de Android. Necesito saber si hay algún intento de abrir la ventana Crear mensaje. Probé con este código -Android: Mensaje de intención

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

embargo, plantea, Gmail, Email & Message necesito para elevar único mensaje. En mi aplicación, tengo que integrar esto cuando presiono el botón. ¿Alguien puede saber esto? Guíame.

Respuesta

7

Puede simplemente en el archivo XML añadir

android:onClick = "onClick" 

y en la actividad:

//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

Si esto funciona bien. Gracias. –

+0

Si puedes simplemente mi respuesta :) – goodm

+1

No puedo aceptarlo ahora. Me dice "Solo puede aceptar esta respuesta en 3 minutos. –

0

supongo que esto debería funcionar:

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

Gracias por su valiosa información. –

1

Esto le ayudará a:

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

Gracias por su valiosa información. –

4

Prueba esto:

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

uso como este para todas las aplicaciones aceptará esta intención

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; 
Cuestiones relacionadas