I have a working application which shares images over WhatsApp. I used mime type
to redirect selected image to WhatsApp.
But when the attachment of image is selected from the chat/WhatsAppand after selecting my application it start again with the list of various contacts in WhatsApp.
What I want is to share image directly in the chat box using my application. Here please understand by this:
When attachment is selected
directed to apps main page
Random image selected and shared to whatsapp
But it sends to contacts and groups instead the chat box :(
Here goes my sharing code:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
ImageView image = (ImageView) findViewById(R.id.full_image_view);
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
File sd = Environment.getExternalStorageDirectory();
String fileName = "desi.png";
File dest = new File(sd, fileName);
try {
FileOutputStream out;
out = new FileOutputStream(dest);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
switch (item.getItemId()) {
case R.id.item:
Uri uri = Uri.fromFile(dest);
Intent shareIntent = new Intent();
shareIntent.setPackage("com.whatsapp");
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share)));
return true;