vm budget error in tabhost activitygroup android
<p>we have used tabhost with activitygroup in our applciation with 10 activities in application when i navigate 5 to 6 times in tab i got following exception in tabhost bexcause of heap size </p>

<pre><code>01-28 21:00:40.480: E/AndroidRuntime(8686): Uncaught handler: thread main exiting due to uncaught exception
01-28 21:00:40.495: E/AndroidRuntime(8686): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.milagemaster/com.milagemaster.Activity_ViewDetails}: android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2335)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.milagemaster.Activity_ShowData.menuClick(Activity_ShowData.java:427)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.milagemaster.Activity_ShowData.onOptionsItemSelected(Activity_ShowData.java:391)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.Activity.onMenuItemSelected(Activity.java:2170)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:525)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.View.onTouchEvent(View.java:4179)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.widget.TextView.onTouchEvent(TextView.java:6591)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.View.dispatchTouchEvent(View.java:3709)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.os.Looper.loop(Looper.java:123)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.ActivityThread.main(ActivityThread.java:4363)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at java.lang.reflect.Method.invokeNative(Native Method)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at java.lang.reflect.Method.invoke(Method.java:521)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at dalvik.system.NativeStart.main(Native Method)
01-28 21:00:40.495: E/AndroidRuntime(8686): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at com.milagemaster.Activity_ViewDetails.onCreate(Activity_ViewDetails.java:46)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-28 21:00:40.495: E/AndroidRuntime(8686):     ... 26 more
01-28 21:00:40.495: E/AndroidRuntime(8686): Caused by: java.lang.reflect.InvocationTargetException
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.widget.RelativeLayout.&lt;init&gt;(RelativeLayout.java:171)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at java.lang.reflect.Constructor.constructNative(Native Method)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
01-28 21:00:40.495: E/AndroidRuntime(8686):     ... 34 more
01-28 21:00:40.495: E/AndroidRuntime(8686): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:447)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.content.res.Resources.loadDrawable(Resources.java:1705)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.View.&lt;init&gt;(View.java:1850)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.View.&lt;init&gt;(View.java:1799)
01-28 21:00:40.495: E/AndroidRuntime(8686):     at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:283)
01-28 21:00:40.495: E/AndroidRuntime(8686):     ... 38 more
</code></pre>

<p>here i got bitmap size exceeds vmbudget error but i have not used more than 1.5 mb images in my application</p>

<p>here is my tabactivity</p>

<pre><code>package com.milagemaster;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TextView;

import com.milagemaster.utility.Global;

public class Activity_tab extends TabActivity implements OnTabChangeListener, LocationListener {
    private static String TAG_AddData;
    private static String TAG_ShowData;
    private static String TAG_Share;
    private static String TAG_Setup;
    private static String TAG_about;
    private static String TAG_More;
    private static String TAG_import;
    private static String TAG_Export;
    private static String TAG_Favorites;
    private static String TAG_Language;
    private LocationManager locationManager = null;
    private SharedPreferences settings;
    private boolean isCurrent = false;
    private boolean isVehicle = false;

    // private TabHost host = null;
    public static void launch(Context mCon) {
        Intent intent = new Intent(mCon, Activity_tab.class);
        mCon.startActivity(intent);

    }

    @SuppressWarnings("deprecation")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab);

        Global.context = this;
        settings = getSharedPreferences(Global.PREF_NAME, Context.MODE_PRIVATE);
        Global.SetCurrentLocale(this);

        TAG_AddData = getString(R.string.Add);
        TAG_ShowData = getString(R.string.show);
        TAG_Share = getString(R.string.share);
        TAG_Setup = getString(R.string.setup);
        TAG_about = getString(R.string.about);
        TAG_More = getString(R.string.more);
        TAG_import = getString(R.string.importcsv);
        TAG_Export = getString(R.string.exportcsv);
        TAG_Favorites = getString(R.string.favorite);
        TAG_Language = getString(R.string.langauge);

        try {

            isCurrent = this.getIntent().getExtras().getBoolean("isCurrent");

        } catch (Exception e) {
            e.printStackTrace();
        }
        try {

            isVehicle = this.getIntent().getExtras().getBoolean("isVehicle");

        } catch (Exception e) {
            e.printStackTrace();
        }

        Log.d("isCurrent", "isCu" + isCurrent);
        if (isCurrent) {
            Log.d("isCurrent", "in if From home");
            Global.CurrentTab = 1;
        } else {
            int setupTag = settings.getInt("ID", -1);
            Log.d("isCurrent", "in Else" + setupTag);
            if (setupTag != -1) {
                if (isVehicle) {
                    Global.CurrentTab = 3;
                } else {
                    Global.CurrentTab = 0;
                }
            }
        }

        try {

            // get location manager to get GPS location
            locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            Location lastLocation = locationManager.getLastKnownLocation(locationManager.GPS_PROVIDER);
            if (lastLocation != null) {
                Global.lat = lastLocation.getLatitude();
                Global.lon = lastLocation.getLongitude();
                Log.i("LAST LOCATION", Global.lat + " | " + Global.lon);
            }

        } catch (Exception e) {
            e.printStackTrace();
            Log.e("Error in getGPS", e.toString());
        }
        Global.host = getTabHost();
        Global.host.addTab(Global.host.newTabSpec(TAG_AddData).setIndicator(TAG_AddData, getResources().getDrawable(R.drawable.tab_add))
                .setContent(new Intent(this, Activity_home.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_ShowData).setIndicator(TAG_ShowData, getResources().getDrawable(R.drawable.tab_show))
                .setContent(new Intent(this, Show_ActivityGroups.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_Share).setIndicator(TAG_Share, getResources().getDrawable(R.drawable.tab_share))
                .setContent(new Intent(this, Activity_Share.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_Setup).setIndicator(TAG_Setup, getResources().getDrawable(R.drawable.tab_setup))
                .setContent(new Intent(this, Activity_setup.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_about).setIndicator(TAG_about, getResources().getDrawable(R.drawable.tab_info))
                .setContent(new Intent(this, About_activityGroups.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        Global.host.addTab(Global.host.newTabSpec(TAG_import).setIndicator(TAG_import, getResources().getDrawable(R.drawable.tab_import))
                .setContent(new Intent(this, ImportActivityGroups.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        Global.host.addTab(Global.host.newTabSpec(TAG_Export).setIndicator(TAG_Export, getResources().getDrawable(R.drawable.tab_export))
                .setContent(new Intent(this, Activity_export.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_Favorites).setIndicator(TAG_Favorites, getResources().getDrawable(R.drawable.tab_favorite))
                .setContent(new Intent(this, Favorite_activityGroups.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.addTab(Global.host.newTabSpec(TAG_Language).setIndicator(TAG_Language, getResources().getDrawable(R.drawable.tab_language))
                .setContent(new Intent(this, Activity_Language.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        Global.host.addTab(Global.host.newTabSpec(TAG_More).setIndicator(TAG_More, getResources().getDrawable(R.drawable.tab_more))
                .setContent(new Intent(this, Actvity_more.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
        Global.host.getTabWidget().getChildAt(5).setVisibility(View.GONE);
        Global.host.getTabWidget().getChildAt(6).setVisibility(View.GONE);
        Global.host.getTabWidget().getChildAt(7).setVisibility(View.GONE);
        Global.host.getTabWidget().getChildAt(8).setVisibility(View.GONE);
        for (int i = 0; i &lt; Global.host.getTabWidget().getChildCount(); i++) {
            Global.host.getTabWidget().getChildAt(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.inactbg));
            TextView tv = (TextView) Global.host.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(Color.parseColor("#ffffff"));

        }

        TextView tv = (TextView) Global.host.getCurrentTabView().findViewById(android.R.id.title); // for
                                                                                                    // Selected
                                                                                                    // Tab
        tv.setTextColor(Color.parseColor("#000000"));

        Global.host.setOnTabChangedListener(this);
        Global.host.setCurrentTab(Global.CurrentTab);
        Global.host.getTabWidget().getChildAt(Global.CurrentTab).setBackgroundDrawable(getResources().getDrawable(R.drawable.actbg));

    }

    @Override
    public void onTabChanged(String tabId) {
        // TODO Auto-generated method stub
        Log.d("in tab Changed", "" + Global.sharestate);

        Global.csvData.clear();
        try
        {
        for (int i = 0; i &lt; Global.host.getTabWidget().getChildCount(); i++) {
            Global.host.getTabWidget().getChildAt(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.inactbg));
            TextView tv = (TextView) Global.host.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(Color.parseColor("#ffffff"));
        }
        TextView tv = (TextView) Global.host.getCurrentTabView().findViewById(android.R.id.title); // for
                                                                                                    // Selected
                                                                                                    // Tab
        tv.setTextColor(Color.parseColor("#000000"));

        Global.host.getTabWidget().getChildAt(Global.host.getCurrentTab()).setBackgroundDrawable(getResources().getDrawable(R.drawable.actbg));
        Runtime.getRuntime().freeMemory();
        Runtime.getRuntime().gc();
        System.gc();
        }
        catch(OutOfMemoryError e)
        {
            Log.d("Out OF Memory",""+e.toString());
            e.printStackTrace();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            Log.d("in tab",""+e.toString());
        }

    }

    @Override
    public void onLocationChanged(Location location) {

        if (location != null) {

            Global.lat = location.getLatitude();
            Global.lon = location.getLongitude();

            Log.i("CURRENT LOCATION", Global.lat + " | " + Global.lon);
        }

    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void onStart() {
        super.onStart();

        System.out.println("System values" + null);
        // call location update method when screen resumed
        //locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000l, 1.0f, this);
    //  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000l, 1.0f, this);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus) {
            // call location update method when screen resumed
            //locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000l, 1.0f, this);
            //locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000l, 1.0f, this);
        }
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();

    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        locationManager = null;
        Global.flag = false;
    }

}
</code></pre>

<p>tabactivity.xml

</p>

<pre><code>&lt;LinearLayout
    android:id="@+id/lLayoutHome"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="0dip"
         &gt;
    &lt;!-- android:background="@drawable/title" --&gt;
        &lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" &gt;

            &lt;FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1" /&gt;

            &lt;ImageView
                android:id="@+id/imageLine"
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="@color/mileage" /&gt;

            &lt;TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:tabStripEnabled="false" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/TabHost&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>Please give me some suggestion
thanks </p>
