Hi i am using a camera application in android. In my application, I want to save the photo that clicked to device's internal storage(in res folder) and also want to share it. I tried the code as shown bellow.
Camera.PictureCallback jpegCallback = new PictureCallback()
{
public void onPictureTaken(byte[] data, Camera camera)
{
FileOutputStream outStream = null;
try
{
outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));
outStream.write(data);
outStream.close();
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
Log.d(TAG, "on pictureTaken" + data.length);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{}
setContentView(R.layout.main2);
BitmapFactory.Options opts = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,opts);
imgView = (ImageView)findViewById(R.id.photoResultView);
imgView.setImageBitmap(bitmap);
upload = (Button) findViewById(R.id.upload);
upload.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("/sdcard/%d.jpg");
sharingIntent.setType("image/jpg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
}
});
}
};
if anyone knows about it help me..