Changing Activities
<p>I am getting an error when ever I switch between my game activity which uses a surfaceview and my other activities using an inflated menu.</p>

<p>Logcat:</p>

<pre><code>07-13 15:15:34.464: ERROR/AndroidRuntime(15103): Uncaught handler: thread main exiting due to uncaught exception
07-13 15:15:34.594: ERROR/AndroidRuntime(15103): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.hitmanassault/com.android.hitmanassault.Hitman}: android.view.InflateException: Binary XML file line #7: Error inflating class &lt;unknown&gt;
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread.access$2200(ActivityThread.java:126)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.os.Looper.loop(Looper.java:123)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread.main(ActivityThread.java:4595)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at java.lang.reflect.Method.invokeNative(Native Method)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at java.lang.reflect.Method.invoke(Method.java:521)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at dalvik.system.NativeStart.main(Native Method)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class &lt;unknown&gt;
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.Activity.setContentView(Activity.java:1629)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.hitmanassault.Hitman.onCreate(Hitman.java:42)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     ... 11 more
07-13 15:15:34.594: ERROR/AndroidRuntime(15103): Caused by: java.lang.reflect.InvocationTargetException
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.hitmanassault.HitmanView.&lt;init&gt;(HitmanView.java:52)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at java.lang.reflect.Constructor.constructNative(Native Method)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     ... 21 more
07-13 15:15:34.594: ERROR/AndroidRuntime(15103): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:464)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:340)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:363)
07-13 15:15:34.594: ERROR/AndroidRuntime(15103):     at com.android.hitmanassault.HitmanView$HitmanThread.&lt;init&gt;(HitmanView.java:158)
</code></pre>

<p>EDIT:Code for Background Image</p>

<pre><code>BitmapFactory.Options options = new BitmapFactory.Options();//Line 156
options.inSampleSize = 2;    // this will cut the sampling by 50%//Line 157
mBackground = BitmapFactory.decodeResource(getResources(),R.drawable.background, options );//Line 158
</code></pre>

<p>EDIT2:Constructor for image</p>

<pre><code>public HitmanThread(SurfaceHolder surfaceHolder, Context context, Handler handler ) {
this.mSurfaceHolder = surfaceHolder;
mHandler = handler;
mContext = context;
mRes = context.getResources();      

paint.setColor(Color.BLACK);

paint.setTextSize(16);

BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;    // this will cut the sampling by 50%
mBackground = BitmapFactory.decodeResource(getResources(),R.drawable.background, options );
    }
</code></pre>

<p>EDIT3:</p>

<p>I tried running my game on a few newer phones using 2.2 and up. It works because without crashing, is there anyway to specify a certain VM budget. Any thing with 16mb or less won't be able to run it sadly. I have 3.4mb of heap with 1mb free any alternative solutions would greatly appreciated. </p>
