ImageView in Android Causing App to Crash
<p>I have an app that is making use of photos stored on either the SD card or directly on the phone.</p>

<p>I have 2 Activities that seem to be having some kind of problem (Acitives for Viewing and Editing a record). A single record references a photo by storing a URI that gives the location of the related photo.</p>

<p>When I click on my View activity, I pass the URI, and then set the ImageView using the URI. When inside the View Activity, I have a menu option that allows you to reach the Edit Activity. When you click Edit, I again pass the URI of the photo, and set the ImageView using the URI. Both of these activities display fine on their own.</p>

<p>However, when I click the Back button to move from Edit to View, the app crashes. Initially the crash was an OutOfMemory Exception. I got past this exception by adding a call to <code>((BitmapDrawable)mImageView.getDrawable()).getBitmap().recycle()</code> in the onPause function in both activities.</p>

<p>With the recycle code in place, execution moves from Edit back to View, and then just crashes somewhere. I've stepped through the lifecycle functions, and execution makes it through successfully, except for onCreate. Execution never reaches onCreate again.</p>

<p>I know it's something related to ImageView because when I remove the ImageView from the layout in my View activity, the crash no longer happens.</p>

<p>Here is the initial stack trace when the crash happens:</p>

<pre><code>Thread [&lt;3&gt; main] (Suspended (exception RuntimeException))  
    ViewRoot.draw(boolean) line: 1356   
    ViewRoot.performTraversals() line: 1097 
    ViewRoot.handleMessage(Message) line: 1613  
    ViewRoot(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 4203    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 521  
    ZygoteInit$MethodAndArgsCaller.run() line: 791  
    ZygoteInit.main(String[]) line: 549 
    NativeStart.main(String[]) line: not available [native method]  
</code></pre>

<p>After this stack trace, if I keep pushing "Step Over" in Eclipse, the stack trace ends up like this:</p>

<pre><code>Thread [&lt;3&gt; main] (Suspended)   
    ThreadGroup.uncaughtException(Thread, Throwable) line: 884  
    NativeStart.main(String[]) line: not available [native method]  
</code></pre>
