I had a little problem where I repeat the same code 3 times, and I'm trying to reduce it to one without success, the code I have is this
public void shared(View view ) {
Intent emailIntent = new Intent( Intent.ACTION_SEND );
emailIntent.setData( Uri.parse( "mailto:" ) );
emailIntent.setType( "text/plain" );
emailIntent.putExtra( Intent.EXTRA_EMAIL, new String[]{} ); // * configurar email aquí!
emailIntent.putExtra( Intent.EXTRA_SUBJECT, " " );
emailIntent.putExtra( Intent.EXTRA_TEXT, mensaje );
//other,whassapp,sGmail
if(other.callOnClick( )){
} else if(sGmail.callOnClick()){
emailIntent.setPackage("com.google.android.gm");
} else if(whassapp.callOnClick()){
emailIntent.setPackage("com.whatsapp");
}
try {
startActivity( Intent.createChooser( emailIntent, "Enviar email." ) );
Log.i( "EMAIL", "Enviando email..." );
} catch (android.content.ActivityNotFoundException e) {
Toast.makeText( this, "NO existe ningún cliente de email instalado!.", Toast.LENGTH_SHORT ).show();
}
}
And what I want is to know how to detect the button pressed since the 3 call to the same method