Android: Take Picture And Save Picture On Sd Card
I want to take a picture with my phone via an application and save the image on my phone. I've tried many of the solutions proposed on the stackoverflow questions but it did not ma
Solution 1:
have you defined the required permissions in your Android manifest like described here?
<manifest... ><uses-featureandroid:name="android.hardware.camera" />
...
</manifest ... >
UPDATE: Ok, remove the brackets after data: data instead of data[]. Then it should work.
Solution 2:
Your code: fos.write(data[0]); is wrong. I am surprised that you did not get an exception
Here is the code I used to save the byte array after taking a picture. "data" is the byte array.
String filePath = outputFileUri.getPath(); // .getEncodedPath();
File file = new File(filePath);
FileOutputStream os;
try {
os = new FileOutputStream(file, true);
os.write(data);
os.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Post a Comment for "Android: Take Picture And Save Picture On Sd Card"