Android: Share Bitmap Not Saved To Sd
I have an app that takes a screenshot and the shares this with the share intent. Rather than save multiple images each time a user wants to simply share the image. Below is the cod
Solution 1:
What I eneded up doing was saving one "Temp" image to the SD/Phone and just overwrite the each time.
Solution 2:
Try using this one:
IntentshareIntent=newIntent();
shareIntent.setAction(Intent.ACTION_SEND);
Uriuri= Uri.parse("android.resource://com.your.app/drawable/" + yourimage);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, shareImage);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Send your image"));
This code works fine for me to send drawables that I use in my app. No pictures saved on sd card. The only problem is that it doesn't work with some social apps :/
Solution 3:
Yes you can send the image without having to save it as a file. From just looking at the code you posted I have no idea how your sending the image but you convert the file with the following:
ByteArrayOutputStreambos=newByteArrayOutputStream();
byte[] data;
if(yourBitmap!=null){
yourBitmap.compress(CompressFormat.PNG, 75, bos);
}elseif (yourBitmap==null){
Log.w("Image going to server is null","Lost in memory");
}
try{
data = bos.toByteArray();
I dont know if your sending the image to another user via your app or what but thats how I use it upload to a server. When your done with the image you would just nullify it all like this.
bos = null;data = null;yourBitmap = null;
Post a Comment for "Android: Share Bitmap Not Saved To Sd"