Android startActivityForResult, setResult, onActivityResult not called

7.8k views Asked by At

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

There are 1 answers

10
Kuffs On BEST ANSWER

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