Skip to content

A picture taking activity that will return you the uri of a CORRECTLY oriented image

Notifications You must be signed in to change notification settings

Mindgrub/MGCameraActivity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

MGCameraActivity

A picture taking activity that will return you the uri of a CORRECTLY oriented image

Due to the unpredictability of Android's camera activities this activity is written for you to take pictures and will return a correctly oriented image.

This Activity can be started like any other activity, simply start it with a desired request code (which you will catch in onActivityResult) and set the desired path for the image to be saved. Here is an example use:

private void startCameraActivity()
{
    //MGCameraActivity can be provided with a preferred filepath for the image, or will generate one if none is included in the extras
    Intent i = new Intent(activity, MGCameraActivity.class);
    i.putExtra(MGCameraActivity.IMAGE_FILE_PATH, activity.getCacheDir().getAbsolutePath() + "/" + String.valueOf(System.currentTimeMillis()));
    activity.startActivityForResult(i, CAMERA_PIC_REQUEST);
}

public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if(requestCode == CAMERA_PIC_REQUEST && resultCode == Activity.RESULT_OK)
    {
    	//if taken from camera, create uri from the included filepath
    	if(data != null && data.hasExtra(MGCameraActivity.IMAGE_FILE_PATH))
    		imageUri = Uri.parse("file://" + data.getStringExtra(MGCameraActivity.IMAGE_FILE_PATH));
    }
} 

About

A picture taking activity that will return you the uri of a CORRECTLY oriented image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages