My android app stops unexpectedly
<p>my app has three buttons that each create a new intent like this:</p>

<pre><code> Button button3 = (Button) findViewById(R.id.Button03);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), Shout.class);
            startActivityForResult(myIntent, 0);
        }

    });
</code></pre>

<p>so basically my other classes in the project start when I click a button. When I want to go back to the first screen I just press the back key.
this works well but after I've pressed the buttons and the back key about 5 times the app crashes. Why? I've noticed that even after I go back from the class, the sensorlistener continues to run at full speed like here:</p>

<pre><code>02-07 16:51:13.034: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.094: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.154: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.214: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.274: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.334: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.394: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.444: INFO/ActivityManager(156): Starting: Intent { cmp=com.bengaard/.Shout } from pid 5354
02-07 16:51:13.504: DEBUG/sensor(5354): onSensorChanged: 2
02-07 16:51:13.564: DEBUG/dalvikvm(5354): GC_EXTERNAL_ALLOC freed 394K, 60% free 3179K/7943K, external 24861K/26873K, paused 34ms
02-07 16:51:13.574: ERROR/dalvikvm-heap(5354): 32980-byte external allocation too large for this process.
02-07 16:51:13.604: ERROR/GraphicsJNI(5354): VM won't let us allocate 32980 bytes
02-07 16:51:13.604: DEBUG/dalvikvm(5354): GC_FOR_MALLOC freed &lt;1K, 60% free 3179K/7943K, external 24861K/26873K, paused 21ms
02-07 16:51:13.614: DEBUG/skia(5354): --- decoder-&gt;decode returned false
02-07 16:51:13.614: DEBUG/AndroidRuntime(5354): Shutting down VM
02-07 16:51:13.614: WARN/dalvikvm(5354): threadid=1: thread exiting with uncaught exception (group=0x40169560)
02-07 16:51:13.614: DEBUG/webviewglue(5354): nativeDestroy view: 0x4dc7e0
02-07 16:51:13.614: DEBUG/webviewglue(5354): nativeDestroy view: 0x47a310
02-07 16:51:13.614: DEBUG/webviewglue(5354): nativeDestroy view: 0x4339e8
02-07 16:51:13.644: ERROR/AndroidRuntime(5354): FATAL EXCEPTION: main
02-07 16:51:13.644: ERROR/AndroidRuntime(5354): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bengaard/com.bengaard.Shout}: android.view.InflateException: Binary XML file line #21: Error inflating class &lt;unknown&gt;
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.os.Looper.loop(Looper.java:123)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread.main(ActivityThread.java:3647)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at java.lang.reflect.Method.invokeNative(Native Method)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at java.lang.reflect.Method.invoke(Method.java:507)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at dalvik.system.NativeStart.main(Native Method)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class &lt;unknown&gt;
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.widget.Toast.makeText(Toast.java:235)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at com.bengaard.Shout.onCreate(Shout.java:57)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     ... 11 more
02-07 16:51:13.644: ERROR/AndroidRuntime(5354): Caused by: java.lang.reflect.InvocationTargetException
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at java.lang.reflect.Constructor.constructNative(Native Method)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     ... 20 more
02-07 16:51:13.644: ERROR/AndroidRuntime(5354): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:450)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:326)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.content.res.Resources.loadDrawable(Resources.java:1740)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.View.&lt;init&gt;(View.java:1951)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.View.&lt;init&gt;(View.java:1899)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:286)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:120)
02-07 16:51:13.644: ERROR/AndroidRuntime(5354):     ... 23 more
02-07 16:51:13.674: WARN/ActivityManager(156):   Force finishing activity com.bengaard/.Shout
02-07 16:51:13.674: WARN/ActivityManager(156):   Force finishing activity com.bengaard/.OB
02-07 16:51:14.174: WARN/ActivityManager(156): Activity pause timeout for HistoryRecord{40a5f000 com.bengaard/.Shout}
02-07 16:51:14.224: ERROR/AK8973(135): Compass driver encountered fatal error2. 
</code></pre>

<p>it looks like an out-of-memory issue, but how can I close down the activities when I click the back button so I won't get this problem, or is there another answer to the problem? Why doesn't the sensorlistener stop after I click the back key? Excuse me for being so noob :o)</p>
