Android的startActivityForResult,的setResult,onActivityResult不叫 [英] Android startActivityForResult, setResult, onActivityResult not called

查看:184
本文介绍了Android的startActivityForResult,的setResult,onActivityResult不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我就开始打电话要求活动的结果是:

I started a phone call Activity requesting for result:

    Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_CALL);
intentcall.setData(Uri.parse("tel:" + phoneNumber));
this.startActivityForResult(intentcall, REQUEST_SLIPDROP_ICON_OFF);

,然后将结果电话监听器是这样的:

And then set the result in phone call listener like this:

    private class MyPhoneStateListener extends PhoneStateListener{
     public void onCallStateChanged(int state, String incomingNumber) {

         super.onCallStateChanged(state, incomingNumber);

         switch (state) {
             case TelephonyManager.CALL_STATE_IDLE:
                                   setResult(Activity.RESULT_OK);
                                   break;

最后,我想关闭在onActivityResult的图标,但没有任何反应。

Finally I want to turn off the icon in onActivityResult, but nothing happens.

    switch (requestCode) {

    case REQUEST_SLIPDROP_ICON_OFF:
        Log.d("request icon off", "request icon off");

        if (resultCode == Activity.RESULT_OK) {     

            changeMenuItem(R.id.fall, R.drawable.fall);
            slipAndDropIconOn = false;

        } 

        break;

什么错吗?请指教!谢谢

Anything wrong? Please advise! thank you

推荐答案

我不认为这个动作会返回一个结果,以便调用 startActivityForResult 无异于调用 startActivity

I don't think this action returns a result so calling startActivityForResult is no different to calling startActivity

请注意这里:输出=无。 的http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL

Note here: output = None. http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL

这篇关于Android的startActivityForResult,的setResult,onActivityResult不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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