onActivityResult没有被调用的子活动调用完成后() [英] onActivityResult is not been invoked after the child activity calls finish()

查看:137
本文介绍了onActivityResult没有被调用的子活动调用完成后()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然有关于该主题的几个问题,我无法找到一个正确的答案。

Though there are several questions regarding this topic, I could not find a right answer to this.

我有一个主要活动(这是一个TabView的一个活动),从那里我打电话的登录活动。

I have a main activity (This is one activity in a tabview) from where I am calling the login activity.

    Button chdbtn=(Button)findViewById(R.id.Add);
    chdbtn.setOnClickListener(new OnClickListener() {   
        @Override
        public void onClick(View v) {
        Intent myIntent = new Intent(main.this, Login.class);
            startActivityForResult(myIntent, 1001);
    }
    }); 


protected void onActivityResult(int requestCode, int resultCode, Intent data){
        if(requestCode == 1001)
        {
            if(resultCode == RESULT_OK)
            {
                          Log.i("Info","Inside");
            }
        }
}

在我登录课,当我点击一个按钮,我这样做

And in my login class, When I click on a button, I am doing this

    Button chdbtn=(Button)findViewById(R.id.Addchild); 
    chdbtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
                Intent Ireturn = new Intent();
                setResult(RESULT_OK,Ireturn);
                finish();
        }
    });

但是,当我登录活动按一下按钮,控制不来的主要活动onActivityResult方法。任何人都可以指导我是什么问题。

But when I click on the button in login activity, the control is not coming to the main activities onActivityResult method. Can anyone guide me what is the issue.

VIJAYapp.sample.ChildEntry1 $ 1 /的onClick:23

VIJAYapp.sample.ChildEntry1$1/onClick:23

信息/ ActivityManager(59):启动活动:意向{CMP = app.sample / .ChildLogin}

INFO/ActivityManager(59): Starting activity: Intent { cmp=app.sample/.ChildLogin }

WARN / ActivityManager(59):startActivity非活动范围内调用;迫使Intent.FLAG_ACTIVITY_NEW_TASK为:意向{CMP = app.sample / .ChildLogin}

WARN/ActivityManager(59): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { cmp=app.sample/.ChildLogin }

DEBUG / PhoneWindow(999):没能挽救其观点着眼,因为细致地查看com.android.internal.policy.impl.PhoneWindow$DecorView@43e4b620没有ID

DEBUG/PhoneWindow(999): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@43e4b620 has no id.

信息/ ActivityManager(59):显示活动app.sample / .ChildLogin:460毫秒(总460毫秒)

INFO/ActivityManager(59): Displayed activity app.sample/.ChildLogin: 460 ms (total 460 ms)

信息/ VIJAY(999):VIJAYapp.sample.ChildLogin $ 1 /的onClick:24

INFO/VIJAY(999): VIJAYapp.sample.ChildLogin$1/onClick:24

以上是上的按钮点击时我得到的日志。我可以看到,有一些问题与Activity..any答案?

Above is the log that I am getting when clicking on the buttons. I can see that there is some problem with the Activity..any answers?

推荐答案

我觉得现在的问题就解决了​​。我做了一些修改,您的code和onActivityResult现在称为(检查修改code:的 http://www.4shared.com/file/_VR3zi28/CopySampleApptar.html ):

I think your problem is solved now. I made some modifications to your code and the onActivityResult is now called (check the modified code: http://www.4shared.com/file/_VR3zi28/CopySampleApptar.html?):

1,当你调用登录活动类应用:的getParent()startActivityForResult(myIntent,1001);

1.-When you call the Login activity class use: getParent().startActivityForResult(myIntent, 1001);

我不是很熟练的机器人,但据我所知,一个控制之间的活动流程是的ActivityGroup类,所以你应该使用的ActivityGroup实例启动活动。在previous线的getParent()提到了的ActivityGroup

I am not very skilled in Android but I understand that the one controlling the flow among activities is the ActivityGroup class, so you should start the activities using the ActivityGroup instance. In the previous line getParent() makes reference to the ActivityGroup.

2,由于您使用的ActivityGroup例如,你的onActivityResult必须放置在类中。

2.-Because you use the ActivityGroup instance, your onActivityResult must be placed in that class as well.

这篇关于onActivityResult没有被调用的子活动调用完成后()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆