Last active
August 29, 2015 14:06
-
-
Save VatslavDS/48fdce895dd347cd1205 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//I have this two methods for read and write in SD memory | |
//THe problems is when i try to retrieve the image the quality is very low. What can i do? | |
//WRITE | |
public String saveToSD(Bitmap outputImage){ | |
//THis create a directory | |
String name_millis = Long.toString(System.currentTimeMillis()); | |
String directory = Environment.getExternalStorageDirectory() + "/.sales_tracker/"; | |
File storagePath = new File(directory); | |
storagePath.mkdirs(); | |
File myImage = new File(storagePath, name_millis + ".jpg"); | |
try { | |
FileOutputStream out = new FileOutputStream(myImage); | |
outputImage.compress(Bitmap.CompressFormat.JPEG, 100, out); | |
out.close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return "/.sales_tracker/" + name_millis + ".jpg"; | |
} | |
//READ | |
public Bitmap readImageFromExternal(String path){ | |
BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inPreferredConfig = Bitmap.Config.ARGB_8888; | |
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + path, options); | |
Bitmap return_bitmap = Bitmap.createScaledBitmap(bitmap, 100, 100, true); | |
return return_bitmap; | |
} | |
//HERE IS THE LOGIC OF SEND IMAGE | |
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); | |
Uri mImage = Uri.fromFile(new File(path)); | |
File file = new File(path); | |
//HERE THE LOG CAT SAY EXIST!!!! | |
if(file.exists()){ | |
Log.v("EXIST", "EXIST"); | |
}else{ | |
Log.v("NOOOO EXIST", "EXIST"); | |
} | |
String [] to = {"[email protected]"}; | |
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, to); | |
emailIntent.putExtra(Intent.EXTRA_SUBJECT, ""); | |
emailIntent.putExtra(Intent.EXTRA_TEXT, "Nombre: " + sentEvidence.get(0) + " Comentario: " + sentEvidence.get(1) | |
+ " Tipo: " + sentEvidence.get(2) + " Marca: " + sentEvidence.get(3)); | |
emailIntent.setType("image/jpeg"); | |
emailIntent.putExtra(Intent.EXTRA_STREAM, mImage); | |
startActivity(emailIntent); | |
//BUT AT THE END NONE IMAGE WAS ATTACHED WHY?!?!? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment