with setonnavigationitemselectedlistener google fragments collapsing bottomnavigation bottom bar android navigation share drawer

setonnavigationitemselectedlistener - Botón Compartir de Android



expandable toolbar android (2)

Quería hacer un botón para compartir en un cajón de navegación, cuando el usuario toca el botón abrirá ese cajón negro con la lista de todas las aplicaciones y el usuario puede compartir el enlace Google play de las aplicaciones. ¿Hay alguna plantilla de código genérico? las únicas respuestas que he encontrado es simplemente compartirlo en una aplicación como Facebook que parece inútil porque no todos usan Facebook.


Use la intención de compartir http://developer.android.com/training/sharing/send.html

Código de muestra

Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send."); sendIntent.setType("text/plain"); startActivity(sendIntent);


Puede enviar contenido invocando un intento implícito con ACTION_SEND.

Para enviar imágenes o datos binarios:

final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/jpg"); final File photoFile = new File(getFilesDir(), "foo.jpg"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile)); startActivity(Intent.createChooser(shareIntent, "Share image using"));

envía una imagen junto con el texto. Esto se puede hacer con:

String text = "Look at my awesome picture"; Uri pictureUri = Uri.parse("file://my_picture"); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, text); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, "Share images..."));

Compartir imágenes múltiples se puede hacer con:

Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); shareIntent.setType("image/*");