Android startActivityForResult, setResult, onActivityResult not called

有些话、适合烂在心里 提交于 2019-12-02 13:57:42

问题


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.

    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


回答1:


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

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



来源:https://stackoverflow.com/questions/20569089/android-startactivityforresult-setresult-onactivityresult-not-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!