una texto sobre reenviar puedo pincel letras letra las imagen historias estado escribir dibujar desde con como colores celular cambiar agrandar android facebook whatsapp share-intent

android - sobre - como reenviar una imagen con texto en whatsapp



Comparte imagen y texto a través de Whatsapp o Facebook. (10)

Tengo en mi aplicación un botón para compartir y quiero compartir una imagen y un texto al mismo tiempo. En GMail funciona bien pero en WhatsApp, solo se envía la imagen y en Facebook se bloquea la aplicación.

El código que uso para compartir es este:

Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_TEXT, "Message"); Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/ford_focus_2014"); try { InputStream stream = getContentResolver().openInputStream(uri); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

Si uso "shareIntent.setType (" * / * ")", Facebook y WhatsApp se bloquean.

Hay alguna manera de hacer esto? Tal vez envié dos mensajes por separado al mismo tiempo (WhatsApp).

Gracias por adelantado.


  1. Copie el texto desde cualquier lugar. Sea Google, Facebook o Whatsapo.

  2. Intente cargar la imagen en whatsapp en cualquier lugar. En el contacto o grupo. Antes de presionar la flecha de enviar imagen ... verá la opción de subtítulos en esa imagen ... toque y mantenga presionada, aparecerá una opción de pegar. se mostrará su texto ... luego podrá enviar la foto y aparecerá con el texto que desea ... ya está ... tendrá el texto y la imagen en él ... el único problema será el Tamaño del texto, que está limitado a cierto número de palabras

😀 Esto funciona solo para usuarios de Android


* Prueba esto

Uri imageUri = Uri.parse(Filepath); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setPackage("com.whatsapp"); shareIntent.putExtra(Intent.EXTRA_TEXT, "My sample image text"); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/jpeg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { startActivity(shareIntent); } catch (android.content.ActivityNotFoundException ex) { ToastHelper.MakeShortText("Kindly install whatsapp first"); }*


A partir de ahora, un Whatsapp Intent admite imágenes y texto:

Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT,title + "/n/nLink : " + link ); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(sharePath)); shareIntent.setType("image/*"); startActivity(Intent.createChooser(shareIntent, "Share image via:"));

La imagen será como está y EXTRA_TEXT se mostrará como el título.


Actualmente, Whatsapp admite el uso compartido de imágenes y texto al mismo tiempo. (Nov 2014).

Aquí hay un ejemplo de cómo hacer esto:

/** * Show share dialog BOTH image and text */ Uri imageUri = Uri.parse(pictureFile.getAbsolutePath()); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); //Target whatsapp: shareIntent.setPackage("com.whatsapp"); //Add text and then Image URI shareIntent.putExtra(Intent.EXTRA_TEXT, picture_text); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/jpeg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { startActivity(shareIntent); } catch (android.content.ActivityNotFoundException ex) { ToastHelper.MakeShortText("Whatsapp have not been installed."); }


Actualmente. Es posible enviar imágenes y texto a través de WhatsApp descargando la imagen en el almacenamiento externo del dispositivo y luego compartir la imagen en WhatsApp.

if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Bitmap bm = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); Intent intent = new Intent(Intent.ACTION_SEND); String share_text = "image and text"; intent.putExtra(Intent.EXTRA_TEXT, notification_share); String path = MediaStore.Images.Media.insertImage(MainActivity.this.getContentResolver(), bm, "", null); Uri screenshotUri = Uri.parse(path); intent.putExtra(Intent.EXTRA_STREAM, screenshotUri); intent.setType("image/*"); startActivity(Intent.createChooser(intent, "Share image via...")); } else { ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); } //The above code works perfect need to show image in an imageView


Esto no es posible, ya que WhatsApp no ​​admite mensajes con imágenes y texto en ellos. Un mensaje puede consistir en una sola imagen, secuencia de texto, archivo de audio, contacto o video. No puedes tener una combinación de ninguno de esos.

Más bien puedes compartir tu texto usando

Intent whatsappIntent = new Intent(Intent.ACTION_SEND); whatsappIntent.setType("text/plain"); whatsappIntent.setPackage("com.whatsapp"); whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share"); try { activity.startActivity(whatsappIntent); } catch (android.content.ActivityNotFoundException ex) { ToastHelper.MakeShortText("Whatsapp have not been installed."); }


Mi segunda respuesta para esta pregunta es: estoy pegando el código completo aquí porque el nuevo desarrollador a veces necesita código completo.

public class ImageSharer extends AppCompatActivity { private ImageView imgView; private Button shareBtn; FirebaseStorage fs; StorageReference sr,sr1; String Img_name; File dir1; Uri uri1; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_sharer); imgView = (ImageView) findViewById(R.id.imgView); shareBtn = (Button) findViewById(R.id.shareBtn); // Initilize firebasestorage instance fs=FirebaseStorage.getInstance(); sr=fs.getReference(); Img_name="10.jpg"; sr1=sr.child("shiva/"+Img_name); final String Paths= Environment.getExternalStorageDirectory()+ File.separator+"The_Bhakti"+File.separator+"Data"; dir1=new File(Paths); if(!dir1.isDirectory()) { dir1.mkdirs(); } sr1.getFile(new File(dir1,Img_name)).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() { @Override public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { sr1.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { uri1= Uri.parse(uri.toString()); } }); } }) ; shareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { uri1=Uri.parse(Paths+File.separator+Img_name); Intent intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*"); //intent.putExtra(intent.EXTRA_SUBJECT,"Insert Something new"); String data = "Hello"; intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(Intent.EXTRA_TEXT,data); intent.putExtra(Intent.EXTRA_STREAM,uri1); intent.setPackage("com.whatsapp"); // for particular choose we will set getPackage() /*startActivity(intent.createChooser(intent,"Share Via"));*/// this code use for universal sharing startActivity(intent); // end Share code } }); }// onCreate closer }


Para compartir texto e imagen en WhatsApp , la versión más controlada del código se encuentra a continuación, puede agregar más métodos para compartir con Twitter , Facebook ...

public class IntentShareHelper { public static void shareOnWhatsapp(AppCompatActivity appCompatActivity, String textBody, Uri fileUri) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.setPackage("com.whatsapp"); intent.putExtra(Intent.EXTRA_TEXT,!TextUtils.isEmpty(textBody) ? textBody : ""); if (fileUri != null) { intent.putExtra(Intent.EXTRA_STREAM, fileUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("image/*"); } try { appCompatActivity.startActivity(intent); } catch (android.content.ActivityNotFoundException ex) { ex.printStackTrace(); showWarningDialog(appCompatActivity, appCompatActivity.getString(R.string.error_activity_not_found)); } } public static void shareOnTwitter(AppCompatActivity appCompatActivity, String textBody, Uri fileUri){...} private static void showWarningDialog(Context context, String message) { new AlertDialog.Builder(context) .setMessage(message) .setNegativeButton(context.getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .setCancelable(true) .create().show(); } }

Para obtener Uri desde un archivo, use la siguiente clase:

public class UtilityFile { public static @Nullable Uri getUriFromFile(Context context, @Nullable File file) { if (file == null) return null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { try { return FileProvider.getUriForFile(context, "com.my.package.fileprovider", file); } catch (Exception e) { e.printStackTrace(); return null; } } else { return Uri.fromFile(file); } } // Returns the URI path to the Bitmap displayed in specified ImageView public static Uri getLocalBitmapUri(Context context, ImageView imageView) { Drawable drawable = imageView.getDrawable(); Bitmap bmp = null; if (drawable instanceof BitmapDrawable) { bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); } else { return null; } // Store image to default external storage directory Uri bmpUri = null; try { // Use methods on Context to access package-specific directories on external storage. // This way, you don''t need to request external read/write permission. File file = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "share_image_" + System.currentTimeMillis() + ".png"); FileOutputStream out = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.PNG, 90, out); out.close(); bmpUri = getUriFromFile(context, file); } catch (IOException e) { e.printStackTrace(); } return bmpUri; } }

Para escribir FileProvider , use este enlace: github.com/codepath/android_guides/wiki/…


Utilice este código para compartir en WhatsApp o en otro paquete con imagen y video. Aquí el URI es el camino de la imagen. Si la imagen en la memoria tardó en cargarse rápidamente y si está utilizando la url, a veces las imágenes no se cargan y los enlaces desaparecen directamente.

shareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { uri1=Uri.parse(Paths+File.separator+Img_name); Intent intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*"); //intent.putExtra(intent.EXTRA_SUBJECT,"Insert Something new"); String data = "Hello"; intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(Intent.EXTRA_TEXT,data); intent.putExtra(Intent.EXTRA_STREAM,uri1); intent.setPackage("com.whatsapp"); startActivity(intent); // end Share code }

Si este código no es comprensible, vea el código completo en mi otra respuesta.


public void shareIntentSpecificApps(String articleName, String articleContent, String imageURL) { List<Intent> intentShareList = new ArrayList<Intent>(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); //shareIntent.setType("image/*"); List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(shareIntent, 0); for (ResolveInfo resInfo : resolveInfoList) { String packageName = resInfo.activityInfo.packageName; String name = resInfo.activityInfo.name; Log.d("System Out", "Package Name : " + packageName); Log.d("System Out", "Name : " + name); if (packageName.contains("com.facebook") || packageName.contains("com.whatsapp")) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, name)); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, articleName); intent.putExtra(Intent.EXTRA_TEXT, articleName + "/n" + articleContent); Drawable dr = ivArticleImage.getDrawable(); Bitmap bmp = ((GlideBitmapDrawable) dr.getCurrent()).getBitmap(); intent.putExtra(Intent.EXTRA_STREAM, getLocalBitmapUri(bmp)); intent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intentShareList.add(intent); } } if (intentShareList.isEmpty()) { Toast.makeText(ArticleDetailsActivity.this, "No apps to share !", Toast.LENGTH_SHORT).show(); } else { Intent chooserIntent = Intent.createChooser(intentShareList.remove(0), "Share Articles"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentShareList.toArray(new Parcelable[]{})); startActivity(chooserIntent); } }

Puede compartir la imagen también lo he hecho en mi aplicación como se menciona en el código anterior.