简体   繁体   English

Android startActivityForResult,setResult,onActivityResult未调用

[英]Android startActivityForResult, setResult, onActivityResult not called

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;

Finally I want to turn off the icon in onActivityResult, but nothing happens. 最后我想关闭onActivityResult中的图标,但没有任何反应。

    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 谢谢

I don't think this action returns a result so calling startActivityForResult is no different to calling startActivity 我不认为此操作返回结果,因此调用startActivityForResult与调用startActivity没有什么不同

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM