How to share image with text as caption on whatsapp etc

  • Thread starter Thread starter Android Central Question
  • Start date Start date
A

Android Central Question

Hi I need help to share image with text as caption on whatsapp etc. but not getting right thing... It sharing only text and if there is no text unable to share anything. can anyone tell me how what need to change with this Using android studio 3.0. Here is code using

public void postShare(Item item) {

String shareText = "";

if (item.getPost().length() > 0) {

shareText = item.getPost();

} else {

if (item.getImgUrl() == null || item.getImgUrl().length() == 0) {

shareText = item.getLink();
}
}

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);

shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, (String) context.getString(R.string.app_name));
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);

if ((item.getImgUrl().length() > 0) && (ContextCompat.checkSelfPermission(this.context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {

ImageView image;
ImageLoader imageLoader = App.getInstance().getImageLoader();

image = new ImageView(context);

if (imageLoader == null) {

imageLoader = App.getInstance().getImageLoader();
}

imageLoader.get(item.getImgUrl(), ImageLoader.getImageListener(image, R.drawable.profile_default_photo, R.drawable.profile_default_photo));

Drawable mDrawable = image.getDrawable();
Bitmap mBitmap = ((BitmapDrawable)mDrawable).getBitmap();

String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), mBitmap, "Image Description", null);

Uri uri = Uri.parse(path);

shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
}

shareIntent.setType("text/plain");

context.startActivity(Intent.createChooser(shareIntent, "Share post"));
}
 
Would you like me to move this to our Developers Lounge forum? Those guys will understand that stuff I expect.
 

Latest posts

Trending Posts

Forum statistics

Threads
956,347
Messages
6,967,699
Members
3,163,516
Latest member
KidColoringPage