• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps creating jpeg file in internal storage

Hello,
I am writing a code for an android app in which I have to captures image and save it into internal storage of android. For this I have written the following code-
Code:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
               		String newPath = PATH+"/"+folderName+"/"+imageName+".jpg";
            		File file = new File( newPath );
            		file.mkdirs();
            		Uri outputFileUri = Uri.fromFile( file );
            		intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            		startActivityForResult(intent, 0);
This code creates jpeg file but don't write the image into it.
Later I tried writing following code in onActivityResult-
Code:
 protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
Bitmap bitmap = (Bitmap) data.getExtras().get("data"); 
        			ByteArrayOutputStream bos = new ByteArrayOutputStream();
        			bitmap.compress(CompressFormat.PNG, 0, bos);
        			byte[] bitmapdata = bos.toByteArray();
        			File file = new File( newPath );
				FileOutputStream fos = new FileOutputStream(file);
				fos.write(bitmapdata);
}
But its still not working. Please help...
 
Back
Top Bottom