Created
November 6, 2011 05:33
-
-
Save jakemoore/1342523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class SaveSnapshotTask extends AsyncTask<Void, Void, File> { | |
@Override | |
protected void onPreExecute() { | |
View progress = findViewById(R.id.progress); | |
progress.setVisibility(View.VISIBLE); | |
} | |
@Override | |
protected File doInBackground(Void... ignore) { | |
File pictureFile = getOutputMediaFile(); | |
if (pictureFile == null){ | |
Log.d(TAG, "Error creating media file, check storage permissions"); | |
return null; | |
} | |
try { | |
FileOutputStream fos = new FileOutputStream(pictureFile); | |
mCurrentBmp.compress(Bitmap.CompressFormat.JPEG, 85, fos); | |
fos.close(); | |
// String uri = MediaStore.Images.Media.insertImage(getContentResolver(), | |
// pictureFile.getAbsolutePath(), pictureFile.getName(), pictureFile.getName()); | |
} catch (FileNotFoundException e) { | |
Log.d(TAG, "File not found: " + e.getMessage()); | |
pictureFile = null; | |
} catch (IOException e) { | |
Log.d(TAG, "Error accessing file: " + e.getMessage()); | |
pictureFile = null; | |
} | |
return pictureFile; | |
} | |
@Override | |
protected void onPostExecute(File file) { | |
View progress = findViewById(R.id.progress); | |
progress.setVisibility(View.GONE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment