Android startActivityForResult, setResult, onActivityResult not called

ksu picture ksu · Dec 13, 2013 · Viewed 7.6k times · Source

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

Answer

Kuffs picture Kuffs · Dec 13, 2013

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