Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/03/2012, 18:51
tazmaniator
 
Fecha de Ingreso: noviembre-2008
Mensajes: 49
Antigüedad: 15 años, 5 meses
Puntos: 4
Pregunta problem,as para mandar un correo desde un dialog con una lista

Buenas tardes, tengo un problema al intentar mandar un correo a traves de un item de una lista de un dialogo me marca errores y me finaliza la actividad, mi clase es la siguiente:

Código JAVA:
Ver original
  1. package mx.unam.tulmovil;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.json.JSONException;
  6.  
  7. import android.app.Activity;
  8. import android.app.AlertDialog;
  9. import android.app.ProgressDialog;
  10. import android.content.Context;
  11. import android.content.DialogInterface;
  12. import android.content.Intent;
  13.  
  14. import android.net.ConnectivityManager;
  15. import android.os.Bundle;
  16. import android.os.Handler;
  17. import android.os.Looper;
  18. import android.os.Message;
  19. import android.util.Log;
  20. import android.view.View;
  21. import android.view.View.OnClickListener;
  22. import android.widget.AdapterView;
  23. import android.widget.AdapterView.OnItemClickListener;
  24. import android.widget.Button;
  25. import android.widget.ImageButton;
  26. import android.widget.LinearLayout;
  27. import android.widget.ListView;
  28. import android.widget.Toast;
  29.  
  30. public class Principal extends Activity implements Runnable{
  31.     /** Called when the activity is first created. */
  32.    
  33.     private AdapterCategorias categorias;
  34.     private AdapterNoticias noticias;
  35.     private ArrayList<Categoria> itemsCategorias;
  36.     private ProgressDialog progreso;
  37.     private ListView listaCat;
  38.     private ListView listaNot;
  39.     private String mail="[email protected]";
  40.     private JSONData webService;
  41.     private Toast msj;
  42.    
  43.     private LinearLayout principal;
  44.     private LinearLayout conexion;
  45.     private Button btnreintentar;
  46.     private ImageButton opciones;
  47.     private Acciones accion;
  48.     @Override
  49.     public void onCreate(Bundle savedInstanceState) {
  50.         super.onCreate(savedInstanceState);
  51.         setContentView(R.layout.main);
  52.         try{
  53.            
  54.             principal=(LinearLayout) findViewById(R.id.lycontenidoprincipal);
  55.             conexion=(LinearLayout) findViewById(R.id.lyconexion);
  56.  
  57.             //this.mostrarPrincipal();
  58.             this.obtenerCategorias();
  59.            
  60.             opciones=(ImageButton) findViewById(R.id.btnopciones);
  61.             opciones.setOnClickListener(opcionesListener);
  62.             categorias.notifyDataSetChanged();
  63.             listaCat=(ListView) findViewById(R.id.categorias);
  64.             listaCat.setAdapter(categorias);
  65.             listaCat.setOnItemClickListener(new OnItemClickListener() {
  66.  
  67.                 public void onItemClick(AdapterView<?> adapter, View view, int position,long id) {
  68.                     // TODO Auto-generated method stub
  69.                       //startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("vnd.youtube:"+lista.videos.get(position).getUrl())));
  70.                 }
  71.             });
  72.          
  73.        
  74.         } catch (Exception e) {
  75.             // TODO: handle exception
  76.         }
  77.     }
  78.    
  79.     public boolean detectarConexion(Context ctx){
  80.         try{
  81.          ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
  82.          return cm.getActiveNetworkInfo().isConnectedOrConnecting();
  83.          }catch(Exception ex){
  84.              return false;
  85.          }
  86.     }
  87.    
  88.     private void mostrarPrincipal(){
  89.         if(this.detectarConexion(this)){
  90.            progreso=ProgressDialog.show(this, "UNAM en YouTube", "Cargando...",true);
  91.        
  92.           Thread spin=new Thread(this);
  93.           spin.start();
  94.         }else{
  95.             principal.setVisibility(LinearLayout.GONE);
  96.             conexion.setVisibility(LinearLayout.VISIBLE);
  97.             btnreintentar=(Button) findViewById(R.id.btnreintentar);
  98.             btnreintentar.setOnClickListener(reintentarListener);
  99.         }
  100.     }
  101.  
  102.     public void run() {
  103.         // TODO Auto-generated method stub
  104.         this.obtenerPrincipal();
  105.     }
  106.    
  107.     public void obtenerPrincipal(){
  108.         try{
  109.             Looper.prepare();
  110.            
  111.             this.obtenerCategorias();
  112.             cargarListas.sendEmptyMessage(0);
  113.             Looper.loop();
  114.             Looper.myLooper().quit();
  115.            
  116.         }catch (Exception e) {
  117.             // TODO: handle exception
  118.         }
  119.     }
  120.    
  121.     public void obtenerCategorias() throws JSONException, Exception{
  122.         webService=new JSONData("http://gama.dgsca.unam.mx/iunamdev/movil/webservice/webserviceCategorias.php");
  123.         itemsCategorias=webService.getListaCategorias();
  124.         categorias=new AdapterCategorias(this,itemsCategorias);
  125.     }
  126.    
  127.     private Handler cargarListas= new Handler(){
  128.         public void handleMessage(Message msg){
  129.            
  130.             conexion.setVisibility(LinearLayout.GONE);
  131.             principal.setVisibility(LinearLayout.VISIBLE);
  132.             accion=new Acciones();
  133.             opciones=(ImageButton) findViewById(R.id.btnopciones);
  134.             opciones.setOnClickListener(opcionesListener);
  135.             categorias.notifyDataSetChanged();
  136.             listaCat=(ListView) findViewById(R.id.categorias);
  137.             listaCat.setAdapter(categorias);
  138.             listaCat.setOnItemClickListener(new OnItemClickListener() {
  139.  
  140.                 public void onItemClick(AdapterView<?> adapter, View view, int position,long id) {
  141.                     // TODO Auto-generated method stub
  142.                       //startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("vnd.youtube:"+lista.videos.get(position).getUrl())));
  143.                 }
  144.             });
  145.             progreso.dismiss();
  146.         }
  147.     };
  148.    
  149.     private OnClickListener reintentarListener=new OnClickListener() {
  150.        
  151.         public void onClick(View v) {
  152.             // TODO Auto-generated method stub
  153.             mostrarPrincipal();
  154.         }
  155.     };
  156.    
  157.     private OnClickListener opcionesListener=new OnClickListener() {
  158.        
  159.         public void onClick(View v) {
  160.             // TODO Auto-generated method stub
  161.             //accion.mostrarOpciones(Principal.this);
  162.             crearDialogoSeleccion();
  163.         }
  164.     };
  165.    
  166.     private void crearDialogoSeleccion()
  167.     {
  168.         final String[] items = {"Enviar Sugerencia", "Recomendaciones"};
  169.      
  170.         AlertDialog.Builder builder = new AlertDialog.Builder(this);
  171.      
  172.         builder.setTitle("Selección");
  173.         builder.setItems(items, new DialogInterface.OnClickListener() {
  174.             public void onClick(DialogInterface dialog, int item) {
  175.                 if(items[item].equals("Enviar Sugerencia"))
  176.                     enviarMail();
  177.                 else if(items[item].equals("Recomendaciones"))
  178.                     Log.i("opcion seleccionada","Mostrar recomendaciones");
  179.             }
  180.         });
  181.      
  182.         builder.create();
  183.         builder.show();
  184.     }
  185.    
  186.     private void enviarMail(){
  187.         Intent correo = new Intent(Intent.ACTION_SEND);
  188.         /*String contenido="Sugerencia o comentario enviado por:\n\nSugerencia:\n\n";
  189.         correo.setType("plain/text");
  190.         correo.putExtra(Intent.EXTRA_EMAIL, new String[] {mail});
  191.         correo.putExtra(Intent.EXTRA_TEXT, contenido);
  192.         setResult(RESULT_OK, correo);*/
  193.         startActivity(correo);
  194.     }
  195.    
  196. }

y este es el error que me saca:

android.content.ActivityNotFoundException: Not Activty found to handle intent {act=android.intent.action.send type=plain/text(has extras)}

espero me puedan ayudar