I wants to send an image stored in the drawable folder to some other app using ACTION_SEND ,my code is given below:
if(view.getId()==R.id.sendimage) {
Uri imageUri=Uri.parse("android.resource://"+getPackageName()+"/drawable"+R.drawable.screen);
intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM,imageUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
chooser=intent.createChooser(intent,"Send Image Via");
startActivity(chooser);
}
But when i try to send using button in my app to Gmail a toast message "Can't attach empty file " appears and similar message also appear in other apps too while sending and some app even crashes. So could you please help me in figuring out the mistake??