0

我有以下活动组

public class ActivityStack extends ActivityGroup{

    public static int settingsFlag=0;
    private Stack<String> stack;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (stack == null)
            stack = new Stack<String>();
        // start default activity
        settingsFlag=1;
        push("FirstStackActivity", new Intent(this, ChannelsActivity.class));
    }

    @Override
    public void finishFromChild(Activity child) {
        pop();
    }

    @Override
    public void onBackPressed() {
        pop();
    }

    public void push(String id, Intent intent) {



        Window window = getLocalActivityManager().startActivity(id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
        if (window != null) {
            stack.push(id);    

            setContentView(window.getDecorView());
        }

    }

    public void pop() {
        if (stack.size() == 1)
        {
            if (getParent() instanceof MainActivity) {
                ((MainActivity) getParent()).changeToMainTabs();
            } 
        } else {
        LocalActivityManager manager = getLocalActivityManager();
        manager.destroyActivity(stack.pop(), true);
        if (stack.size() > 0) {
            Intent lastIntent = manager.getActivity(stack.peek()).getIntent();
            Window newWindow = manager.startActivity(stack.peek(), lastIntent);    
            setContentView(newWindow.getDecorView());
        }
        }
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        //what is the current activity?
        menu.add(0, 0, 0, "holder");
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu)
    {
        //start a new
        menu.clear();
        //add some menu options
        getLocalActivityManager().getCurrentActivity().onPrepareOptionsMenu(menu);
        return super.onPrepareOptionsMenu(menu);
    }
}

我在另一个活动中有这段代码:

editTxt.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                            Intent countryIntent = new Intent();
                                                    countryIntent.setClass(getParent(),Test.class);
                            //startActivityForResult(countryIntent, requestCode);

                            ActivityStack activityStack = (ActivityStack) getParent();
                            **activityStack.push("SecondActivity", startActivityForResult(countryIntent, requestCode)); //!!THIS SI NOW WORKING CASE IT EXPECTS AN INTENT**
                        }
                    });

我怎样才能使这项工作?有人可以帮忙吗?

4

1 回答 1

2

对于接收推送,请在您的主要组活动中尝试以下代码'

   @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
//code for receive the data
    } 

意思是把上面的代码放在ActivityStack活动中

于 2013-05-27T08:20:47.810 回答