Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Juan ladron de guevara
Juan ladron de guevara
3,335 Points

How to make a Camera APP that returns me a picture in Portrait mode?

Hello everyone,

I am working in my first app for Android (beyond the exercises of Treehouse) and i am building a camera App , at the moment i write a intent to call the Camera of the device, so i can take the picture and return the bitmap to a ImageView, the problem in which i had been stuck for several days i that i can´t make the picture to appear in portrait mode, it returns me the picture in landscape by default, even when i took the picture in portrait. I tried several things now, i read already the Android documentation but its quite confusing.

Can somebody please help me with it, i will write you my Java code here so you can take a look.


import android.content.Intent; import android.graphics.Bitmap; import android.provider.MediaStore; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageView;

public class MainActivity extends ActionBarActivity {

ImageView iv;

protected void onCreate(Bundle savedInstanceState) {

    iv = (ImageView) findViewById(R.id.imageView);

    Button btn = (Button) findViewById(R.id.takePhoto);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);



protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 0)

        Bitmap theImage = (Bitmap) data.getExtras().get("data");



public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;

public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;

    return super.onOptionsItemSelected(item);