Infinite loading image screen
<p>My apologies if this question has already been asked, but I have an issue with my code seeming to get stuck at some point and just indefinitely trying to load an image on my tablet's (Nexus 7) cropping program. My program is supposed to allow a user to take a picture and then crop it. From there I will add more, but that part hasn't been added in yet. Perhaps my problem is a missing line in my manifest? Logcat pops up a line "V 03-06 13:43:52.296 7349 7349 StateManager destroy" after i go to crop the image. I am using the Eclipse IDE and used this site to help make this part of my program: <a href="http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/" rel="nofollow">http://mobile.tutsplus.com/tutorials/android/capture-and-crop-an-image-with-the-device-camera/</a></p>

<p>Here's a snippet of what I think all is needed in the Manifest:</p>

<pre><code>&lt;uses-permission android:name="android.permission.CAMERA" /&gt;
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
&lt;uses-feature android:name="android.hardware.camera" android:required="true" /&gt;
&lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;
</code></pre>

<p>Here's the xml, there should be nothing wrong here:</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Scan" &gt;

&lt;Button
    android:id="@+id/capture_btn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="@string/capture" /&gt;

&lt;ImageView
    android:id="@+id/picture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/capture_btn"
    android:layout_centerHorizontal="true"
    android:background="@drawable/pic_border"
    android:contentDescription="@string/picture" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>Lastly, here's the .java file:</p>

<pre><code>import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import android.support.v4.app.NavUtils;

public class Scan extends Activity implements OnClickListener {

//keep track of camera capture intent
final int CAMERA_CAPTURE = 1;
//captured picture uri
private Uri picUri;
//keep track of cropping intent
final int PIC_CROP = 2;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);
    // Show the Up button in the action bar.
    getActionBar().setDisplayHomeAsUpEnabled(true);

    //retrieve a reference to the UI button
    Button captureBtn = (Button)findViewById(R.id.capture_btn);
    //handle button clicks
    captureBtn.setOnClickListener(this);


}

@Override
public void onClick(View v) {
    if (v.getId() == R.id.capture_btn) {
        try {
            //use standard intent to capture an image
            Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //we will handle the returned data in onActivityResult
            startActivityForResult(captureIntent, CAMERA_CAPTURE);
        }
        catch(ActivityNotFoundException anfe){
            //display an error message
            String errorMessage = "Whoops! Your device doesn't support image capturing!";
            Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
            toast.show();
        }
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        //user is returning from capturing an image using the camera
        if(requestCode == CAMERA_CAPTURE){
            //get the Uri for the captured image
            picUri = data.getData();
            //carry out the crop operation
            performCrop();
        }
        //user is returning from cropping the image
        else if(requestCode == PIC_CROP){
            //get the returned data
            Bundle extras = data.getExtras();
            //get the cropped bitmap
            Bitmap thePic = extras.getParcelable("data");
            //retrieve a reference to the ImageView
            ImageView picView = (ImageView)findViewById(R.id.picture);
            //display the returned cropped image
            picView.setImageBitmap(thePic);
        }
    }
}

private void performCrop(){
    try {
        //call the standard crop action intent (the user device may not support it)
        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        //indicate image type and Uri
        cropIntent.setDataAndType(picUri, "image/*");
        //set crop properties
        cropIntent.putExtra("crop", "true");
        //indicate aspect of desired crop
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        //indicate output X and Y. Edit this line for width and height respectively
        cropIntent.putExtra("outputX", 256);
        cropIntent.putExtra("outputY", 256);
        //retrieve data on return
        cropIntent.putExtra("return-data", true);
        //start the activity - we handle returning in onActivityResult
        startActivityForResult(cropIntent, PIC_CROP);
    }
    catch(ActivityNotFoundException anfe){
        //display an error message
        String errorMessage = "Whoops! Your device doesn't support the cropping!";
        Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}
</code></pre>

<p>Note, the problem was that picUri was returned as null.</p>
