使用活动组在标签之间切换,它想显示最后的活动-标签活动组[英] Switching between tab using activity group it want to display last activity - Tab ActivityGroup

本文是小编为大家收集整理的关于使用活动组在标签之间切换,它想显示最后的活动-标签活动组的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我已经为我的 android 应用程序编写了标签.

我的问题是使用要显示最后一个活动的活动组在选项卡之间切换.当我们导航选项卡时,我想显示最后打开/访问的屏幕.我的一个是转到第一个屏幕:

我需要在浏览 Tab 时显示上次打开的屏幕

标签 1 -> 销售.这里面包含 10 个屏幕(活动)Tab 2 -> Admin .这里面包含 5 个屏幕(活动)选项卡 3 -> 设置.这里面包含 8 个屏幕.(活动)

我点击了标签 1,它加载了包含销售路线列表的标签 1 的屏幕.然后我点击了一个销售路线,它转到了第一个标签中的零售商列表.然后我点击了标签 3"设置"完成一些工作回到销售,那个时候它应该在"销售"标签中显示最后打开的屏幕.

当我点击标签时,它应该显示上次打开的活动怎么办?

我喜欢这个.请指出我想根据我的要求更改代码的位置.

MainActivity.它会在登录后调用

  public class MainActivity extends TabActivity {
int selectedTab;
TabHost tabHost ;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabview);

    TabHost t = getTabHost();
    tabHost = (TabHost)findViewById(android.R.id.tabhost);

    TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
    TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
    TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
    /** TabSpec setIndicator() is used to set name for the tab. */
    /** TabSpec setContent() is used to set content for a particular tab. */
    firstTabSpec.setIndicator("Sales").setContent(new Intent(this,SalesActivityGroup.class));
    secondTabSpec.setIndicator("Admin").setContent(new Intent(this,SettingActivityGroup.class));
    thirdTabSpec.setIndicator("Setting").setContent(new Intent(this,SettingActivityGroup.class));


    tabHost.addTab(firstTabSpec);
    tabHost.addTab(secondTabSpec);
    tabHost.addTab(thirdTabSpec);
    tabHost.setCurrentTab(0);
    tabHost.setMinimumHeight(25);
}

public void onTabChanged(String arg0) {
        selectedTab = tabHost.getCurrentTab();

}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        moveTaskToBack(false);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

}

第一个 Tab1(Sales) 的 SalesGroupActivity

 public class SalesActivityGroup extends ActivityGroup {

public static SalesActivityGroup group;
private ArrayList<View> history;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.history = new ArrayList<View>();
    group = this;

    View view = getLocalActivityManager().startActivity("Sales",
            new Intent(this, SalesRouteActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();

    replaceView(view);

}

public void replaceView(View v) {
    history.add(v);
    setContentView(v);

}

public void back() {
    if (history.size() > 0) {
        history.remove(history.size() - 1);
        if (history.size() > 0) {
            setContentView(history.get(history.size() - 1));
        } else {
            finish();
        }
    } else {
        finish();
    }
}

@Override
public void onBackPressed() {
    SalesActivityGroup.group.back();
    return;
}

已编辑这是 FirstTab 的 firstActivity - SalesRouteActivity

    public class SalesRouteActivity extends ListActivity{
     TableLayout tl;
     static int positions = 0;
     static String keyword ="";
     int uploadSize = 0;
     private NotificationManager mNotificationManager;
     private int SIMPLE_NOTFICATION_ID;
     String strBusinessUnit = "";   
     String strExecutive = "";
     String strTerritoryCode = "";
     SimpleAdapter sd;
     View row = null;
     View selectRow = null;

     @Override
     public void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);
         setContentView(R.layout.sales_routes);

         SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_WORLD_READABLE);
         strBusinessUnit = myPrefs.getString("BusinessUnit", "");
         strExecutive = myPrefs.getString("Executive", "");
         strTerritoryCode = myPrefs.getString("TerritoryCode", "");

         ArrayList<SalesRoutes> routeList = getSalesRoute();

         ArrayList<HashMap<String, String>> routhPath = new ArrayList<HashMap<String, String>>();
         for (int i = 0; i < routeList.size(); i++) {
            if(Integer.parseInt(routeList.get(i).getOutlets()) >0){
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("routeCode",((SalesRoutes) routeList.get(i)).getRouteCode());
                map.put("routeName",((SalesRoutes) routeList.get(i)).getDescription());
                map.put("outlets", ((SalesRoutes) routeList.get(i)).getOutlets());
                routhPath.add(map);
             }
         }

         ListView list = getListView();
         sd = new SimpleAdapter(this, routhPath, R.layout.route_path,new String[] {"routeCode","routeName","outlets" },new int[] { R.id.routeCode,R.id.routeName,R.id.outlets});
         row = getLayoutInflater().inflate(R.layout.route_path_row, null, false);
         getListView().addHeaderView(row);
         list.setAdapter(sd);
         list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        list.setSelected(true);
        list.setTextFilterEnabled(true);
        list.setItemsCanFocus(true);
        list.setItemChecked(positions, true);
        list.setSelectionAfterHeaderView();

        if (routeList.size() > 0) {
            keyword = routeList.get(0).getRouteCode();
        }

        uploadSize = new UploadActivity().getUploadTable();

        if (uploadSize > 0) {
            mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            final Notification notifyDetails = new Notification(R.drawable.icon, "New Alert, Click Me!",System.currentTimeMillis());
            Context context = getApplicationContext();
            CharSequence contentTitle = "Upload Available...";
            CharSequence contentText = "Browse Android Official Site by clicking me";
            Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
            PendingIntent intent = PendingIntent.getActivity(SalesRouteActivity.this, 0, notifyIntent,android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
            notifyDetails.setLatestEventInfo(context, contentTitle,contentText, intent);
            mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
        }
    }

    @SuppressWarnings("unchecked")
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        HashMap<String, String> hashMap = (HashMap<String, String>) l.getItemAtPosition(position);
        keyword = hashMap.get("routeCode");

        positions = position;
        if(position == 0 ){


        }else if(position != 1){
            Intent showContent = new Intent(v.getContext(),SalesRouteDevitionActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("RouteCode", keyword);
            showContent.putExtras(bundle);
            getParent().startActivityForResult(showContent, 5);
        }else{
            Intent intent = new Intent(SalesRouteActivity.this, ListRetailerActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("RouteName", keyword);
            intent.putExtras(bundle);
            View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();  
            SalesActivityGroup.group.replaceView(view);

        }
    }

    @Override  
    public void onBackPressed() {  
        SalesActivityGroup.group.back();  
    } 

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public ArrayList<SalesRoutes> getSalesRoute(){
         DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
          try {
              dbAdapter.createDataBase();
         } catch (IOException e) {
              Log.i("*** select ",e.getMessage());
         }
         dbAdapter.openDataBase();       
         String sql = "SELECT RouteCode, Description, OutletsAttached  " +
                       "FROM WMRoute  " +
                       "WHERE ActiveStatus = '1' AND  RouteDefaultExecutive = ? AND  BusinessUnit = ? AND TerritoryCode = ?  " +
                       "ORDER BY RouteCode  ";

         String[]d = new String[]{strExecutive,strBusinessUnit,strTerritoryCode};
         ArrayList stringList = dbAdapter.selectRecordsFromDBList(sql, d);
         dbAdapter.close();
         ArrayList<SalesRoutes> salesRoutesList = new ArrayList<SalesRoutes>();
         for (int i = 0; i < stringList.size(); i++) {
            ArrayList<Object> arrayList = (ArrayList<Object>) stringList.get(i);
            ArrayList<Object> list = arrayList;
            SalesRoutes salesRoutes = new SalesRoutes();
            try {
                salesRoutes.setRouteCode((String) list.get(0));
                salesRoutes.setDescription((String) list.get(1));
                salesRoutes.setOutlets((String)list.get(2));

            } catch (Exception e) {
                Log.i("***" + SalesRouteActivity.class.toString(), e.getMessage());
            }
            salesRoutesList.add(salesRoutes);
        }
        return salesRoutesList;
    }
}

当您在选项卡之间切换时,我的 ActivityGroup 可能会一次又一次地被创建所以小组只想创建一次并在我在标签之间切换时恢复

数据库中获取的每个屏幕详细信息/内容..

我遇到这个问题超过 2 天了......请帮助我.请帮我解决这个问题....

提前致谢.....

推荐答案

谢谢大家;

我的 MainActivity 出现问题.

 tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;


    intent = new Intent().setClass(this, SalesActivityGroup.class);  
    spec = getTabHost().newTabSpec("Sales").setIndicator("Sales",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Admin").setIndicator("Admin",getResources().getDrawable(R.drawable.admin)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Setting").setIndicator("Setting",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Inquiry").setIndicator("Inquiry",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);


    tabHost.setCurrentTab(0);
    tabHost.setMinimumHeight(18);
    tabHost.setFadingEdgeLength(5);
    tabHost.setFocusable(true); 
    tabHost.requestFocus();
    tabHost.setFadingEdgeLength(5);
  }
}

我同意@Vaibhav Jani @Dharmendra @Suri,我在所有活动中都错过了 onKeyPressed().

其他推荐答案

我认为你必须在 activity-group 中打开的活动中覆盖 onBackPressed()

在您在活动组中打开的每个活动中编写下面的代码

@Override  
public void onBackPressed() {  
       SalesActivityGroup.group.back();  
} 

并且还用TABHOST

中的以下代码替换onBackPressed()
@Override
public void onBackPressed() {
    super.onBackPressed();
}

祝你好运

其他推荐答案

您创建的活动组将保留您当前的活动视图,除非您更改它,否则不会更改,因此,当您在选项卡之间导航时,您已分配的活动组那些标签不会改变它们的视图将保持原样.

你可以试试这个....

对于您的每个活动,您必须覆盖 onBackPressed() ...

@Override  
public void onBackPressed() {  
       ActivityGroupRelatedToThisActivity.group.back();  
} 

还要记住不要在与活动组相关的任何活动中调用 super.onBackPressed()

将 private ArrayList<View> history 改为 static private ArrayList<View> history

if(history.size() == 0) replaceView(view); 

在ActivityGroup的onCreate()方法中

本文地址:https://www.itbaoku.cn/post/102393.html

问题描述

I have written tab for my android application.

My question is switching between tab using activity group it want to display last activity. I want to show last open/visited screen when we navigate the tab.My one is go to first screen:

I need to show last opened screen when navigate through Tab

Tab 1 -> Sales. This contain 10 screen inside (actiivity) Tab 2 -> Admin .This contain 5 screen inside (actiivity) Tab 3 -> Setting.This contain 8 screen inside. (actiivity)

I clicked Tab 1 , it load tab 1's screen which is contain list of sales route .then I clicked one sales route , it goes to list of retailer in the first tab.Then I cliched tab 3 "Setting " finish some work & come back to sales, That time it should show last open screen in the "sales" tab.

When I clicked tab, It should show last open activity How to do?

I did like this.Please indicate where I want to change the code for my requirements.

MainActivity.It will call after login

  public class MainActivity extends TabActivity {
int selectedTab;
TabHost tabHost ;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabview);

    TabHost t = getTabHost();
    tabHost = (TabHost)findViewById(android.R.id.tabhost);

    TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
    TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
    TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
    /** TabSpec setIndicator() is used to set name for the tab. */
    /** TabSpec setContent() is used to set content for a particular tab. */
    firstTabSpec.setIndicator("Sales").setContent(new Intent(this,SalesActivityGroup.class));
    secondTabSpec.setIndicator("Admin").setContent(new Intent(this,SettingActivityGroup.class));
    thirdTabSpec.setIndicator("Setting").setContent(new Intent(this,SettingActivityGroup.class));


    tabHost.addTab(firstTabSpec);
    tabHost.addTab(secondTabSpec);
    tabHost.addTab(thirdTabSpec);
    tabHost.setCurrentTab(0);
    tabHost.setMinimumHeight(25);
}

public void onTabChanged(String arg0) {
        selectedTab = tabHost.getCurrentTab();

}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        moveTaskToBack(false);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

}

First Tab1(Sales)'s SalesGroupActivity

 public class SalesActivityGroup extends ActivityGroup {

public static SalesActivityGroup group;
private ArrayList<View> history;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.history = new ArrayList<View>();
    group = this;

    View view = getLocalActivityManager().startActivity("Sales",
            new Intent(this, SalesRouteActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();

    replaceView(view);

}

public void replaceView(View v) {
    history.add(v);
    setContentView(v);

}

public void back() {
    if (history.size() > 0) {
        history.remove(history.size() - 1);
        if (history.size() > 0) {
            setContentView(history.get(history.size() - 1));
        } else {
            finish();
        }
    } else {
        finish();
    }
}

@Override
public void onBackPressed() {
    SalesActivityGroup.group.back();
    return;
}

Edited This is FirstTab's firstActivity - SalesRouteActivity

    public class SalesRouteActivity extends ListActivity{
     TableLayout tl;
     static int positions = 0;
     static String keyword ="";
     int uploadSize = 0;
     private NotificationManager mNotificationManager;
     private int SIMPLE_NOTFICATION_ID;
     String strBusinessUnit = "";   
     String strExecutive = "";
     String strTerritoryCode = "";
     SimpleAdapter sd;
     View row = null;
     View selectRow = null;

     @Override
     public void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);
         setContentView(R.layout.sales_routes);

         SharedPreferences myPrefs = this.getSharedPreferences("myLogedPrefs",MODE_WORLD_READABLE);
         strBusinessUnit = myPrefs.getString("BusinessUnit", "");
         strExecutive = myPrefs.getString("Executive", "");
         strTerritoryCode = myPrefs.getString("TerritoryCode", "");

         ArrayList<SalesRoutes> routeList = getSalesRoute();

         ArrayList<HashMap<String, String>> routhPath = new ArrayList<HashMap<String, String>>();
         for (int i = 0; i < routeList.size(); i++) {
            if(Integer.parseInt(routeList.get(i).getOutlets()) >0){
                HashMap<String, String> map = new HashMap<String, String>();
                map.put("routeCode",((SalesRoutes) routeList.get(i)).getRouteCode());
                map.put("routeName",((SalesRoutes) routeList.get(i)).getDescription());
                map.put("outlets", ((SalesRoutes) routeList.get(i)).getOutlets());
                routhPath.add(map);
             }
         }

         ListView list = getListView();
         sd = new SimpleAdapter(this, routhPath, R.layout.route_path,new String[] {"routeCode","routeName","outlets" },new int[] { R.id.routeCode,R.id.routeName,R.id.outlets});
         row = getLayoutInflater().inflate(R.layout.route_path_row, null, false);
         getListView().addHeaderView(row);
         list.setAdapter(sd);
         list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        list.setSelected(true);
        list.setTextFilterEnabled(true);
        list.setItemsCanFocus(true);
        list.setItemChecked(positions, true);
        list.setSelectionAfterHeaderView();

        if (routeList.size() > 0) {
            keyword = routeList.get(0).getRouteCode();
        }

        uploadSize = new UploadActivity().getUploadTable();

        if (uploadSize > 0) {
            mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            final Notification notifyDetails = new Notification(R.drawable.icon, "New Alert, Click Me!",System.currentTimeMillis());
            Context context = getApplicationContext();
            CharSequence contentTitle = "Upload Available...";
            CharSequence contentText = "Browse Android Official Site by clicking me";
            Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
            PendingIntent intent = PendingIntent.getActivity(SalesRouteActivity.this, 0, notifyIntent,android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
            notifyDetails.setLatestEventInfo(context, contentTitle,contentText, intent);
            mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
        }
    }

    @SuppressWarnings("unchecked")
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        HashMap<String, String> hashMap = (HashMap<String, String>) l.getItemAtPosition(position);
        keyword = hashMap.get("routeCode");

        positions = position;
        if(position == 0 ){


        }else if(position != 1){
            Intent showContent = new Intent(v.getContext(),SalesRouteDevitionActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("RouteCode", keyword);
            showContent.putExtras(bundle);
            getParent().startActivityForResult(showContent, 5);
        }else{
            Intent intent = new Intent(SalesRouteActivity.this, ListRetailerActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("RouteName", keyword);
            intent.putExtras(bundle);
            View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();  
            SalesActivityGroup.group.replaceView(view);

        }
    }

    @Override  
    public void onBackPressed() {  
        SalesActivityGroup.group.back();  
    } 

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public ArrayList<SalesRoutes> getSalesRoute(){
         DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
          try {
              dbAdapter.createDataBase();
         } catch (IOException e) {
              Log.i("*** select ",e.getMessage());
         }
         dbAdapter.openDataBase();       
         String sql = "SELECT RouteCode, Description, OutletsAttached  " +
                       "FROM WMRoute  " +
                       "WHERE ActiveStatus = '1' AND  RouteDefaultExecutive = ? AND  BusinessUnit = ? AND TerritoryCode = ?  " +
                       "ORDER BY RouteCode  ";

         String[]d = new String[]{strExecutive,strBusinessUnit,strTerritoryCode};
         ArrayList stringList = dbAdapter.selectRecordsFromDBList(sql, d);
         dbAdapter.close();
         ArrayList<SalesRoutes> salesRoutesList = new ArrayList<SalesRoutes>();
         for (int i = 0; i < stringList.size(); i++) {
            ArrayList<Object> arrayList = (ArrayList<Object>) stringList.get(i);
            ArrayList<Object> list = arrayList;
            SalesRoutes salesRoutes = new SalesRoutes();
            try {
                salesRoutes.setRouteCode((String) list.get(0));
                salesRoutes.setDescription((String) list.get(1));
                salesRoutes.setOutlets((String)list.get(2));

            } catch (Exception e) {
                Log.i("***" + SalesRouteActivity.class.toString(), e.getMessage());
            }
            salesRoutesList.add(salesRoutes);
        }
        return salesRoutesList;
    }
}

probably my ActivityGroups are being created again and again when you switch between tabs So groups want to create only once and resumed when i switch between tabs

Every screen details/contents getting from database..

I am facing this issue more than 2 days....Please help me. Please help me on this....

Thanks in advance.....

推荐答案

Thanks All;

There were issue in my MainActivity.

 tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;


    intent = new Intent().setClass(this, SalesActivityGroup.class);  
    spec = getTabHost().newTabSpec("Sales").setIndicator("Sales",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Admin").setIndicator("Admin",getResources().getDrawable(R.drawable.admin)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Setting").setIndicator("Setting",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, SettingActivityGroup.class);  
    spec = getTabHost().newTabSpec("Inquiry").setIndicator("Inquiry",getResources().getDrawable(R.drawable.ic_tab_artists_grey)).setContent(intent);
    tabHost.addTab(spec);


    tabHost.setCurrentTab(0);
    tabHost.setMinimumHeight(18);
    tabHost.setFadingEdgeLength(5);
    tabHost.setFocusable(true); 
    tabHost.requestFocus();
    tabHost.setFadingEdgeLength(5);
  }
}

And I agree @Vaibhav Jani @Dharmendra @Suri, I missed that onKeyPressed() in all Activity.

其他推荐答案

I think you have to override onBackPressed() inside activities which you are opening in activity-group

Write a code below in each activity which you are opening in activity-group

@Override  
public void onBackPressed() {  
       SalesActivityGroup.group.back();  
} 

And also replace the onBackPressed() with following code in TABHOST

@Override
public void onBackPressed() {
    super.onBackPressed();
}

Best of luck

其他推荐答案

The activity groups you created will hold your current activity view will not change unless you change it, Therefore while you are navigating between tabs the activity groups you have assigned to those tabs will not change their views will remain as it is.

You can try this ....

For each of your activity you must override onBackPressed() ...

@Override  
public void onBackPressed() {  
       ActivityGroupRelatedToThisActivity.group.back();  
} 

Also remember do not call super.onBackPressed() in any of your Activity which is related to activity group

Or

Change private ArrayList<View> history to static private ArrayList<View> history

and

if(history.size() == 0) replaceView(view); 

in ActivityGroup's onCreate() method