Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent photoPickerIntent= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempFile());
- photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
- photoPickerIntent.putExtra("return-data", true);
- startActivityForResult(Intent.createChooser(photoPickerIntent,"Select Picture"),0);
- public void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- if (resultCode == RESULT_OK)
- {
- if (requestCode == 0)
- {
- photopath= muri.getPath();
- Log.e("path", photopath);
- Toast.makeText(this, photopath,Toast.LENGTH_LONG).show();
- Intent i=new Intent();
- setResult(RESULT_OK,i);
- }}}
- private Uri getTempFile() {
- // if (isSDCARDMounted()) {
- File root = new File(Environment.getExternalStorageDirectory(), "EquipUpdate");
- if (!root.exists()) {
- root.mkdirs();
- }
- File file = new File(root,"android_" + String.valueOf(System.currentTimeMillis()) + ".jpeg" );
- muri = Uri.fromFile(file);
- Log.e("getpath",muri.getPath());
- return muri;
- // } else {
- // return null;
- }
- //}
- private boolean isSDCARDMounted(){
- String status = Environment.getExternalStorageState();
- if (status.equals(Environment.MEDIA_MOUNTED))
- return true;
- else
- return false;
- }
- public String getPath(Uri uri)
- {
- String[] projection = { MediaStore.Images.Media.DATA,MediaStore.Images.ImageColumns.ORIENTATION };
- Cursor cursor = managedQuery(uri, projection, null, null, null);
- int column_index = cursor
- .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- int orientation_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION);
- cursor.moveToFirst();
- orientation = cursor.getString(orientation_ColumnIndex);
- return cursor.getString(column_index);
- }
Add Comment
Please, Sign In to add comment