Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus 6 | Nexus Player | Nexus 9
test: Reply
LinkBack Thread Tools
Old October 3rd, 2012, 12:09 PM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Oct 2012
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Sony Xperia S Camera Intent

I am having problem with storing the image from a camera intent. After hours of testing I finally realised that the problem I had was due to the fact that it was Sony Xperia S I was working on as my HTC desire worked correctly.

I want to take image, and then I want to retrieve it and conert it to byte array and sent it to a wcf.

This is how I try to achieve the storing image part:
 private File getCameraImageFile() {
        String storageState = Environment.getExternalStorageState();
        if (storageState.equals(Environment.MEDIA_MOUNTED)) {
            String path = Environment.getExternalStorageDirectory() +
                "" + File.separatorChar + "download"+ ""+ File.separatorChar+""+ "mypicture.jpg";
            File photoFile = new File(path);
            try {
                if (!photoFile.exists()) {
            } catch (IOException e) {
                Log.e(TAG, "Could not create file.", e);
            Log.i(TAG, "Got a file! " + path);
            return photoFile;
        } else {
            Log.i(TAG, "External storage (SD card) is required. Current state: "
                + storageState);
            // show some error dialog here
            return null;

    public void takePhoto(View view) {
    	Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    	File file = getCameraImageFile();
    	imageUri = Uri.fromFile(file);
    	cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        startActivityForResult(cameraIntent, 32);
How can this be fixed so it can be used on Sony Xperia S, I figure it is because it has an internal memory, not an external device. I have tried using cachedir but then the intent fails with error-code 0. With this code it does not fail, but no image is stored to the download directory but its saved to the gallary.

Solved: The problem was not in the storing of files, my windows explorer did not update the folders so I thought the files had not been saved. However! it was how I in the next step tried to grab the file, with File f = new File(imageUri.toString()); , this works on HTC Desire but not on Sony Xperia S!

Todilo is offline  
Last edited by Todilo; October 3rd, 2012 at 12:20 PM.
Reply With Quote
sponsored links

Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -5. The time now is 12:41 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.