Android startActivityForResult,setResult,onActivityResult未调用
作者:互联网
我打了一个电话,要求提供结果:
Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_CALL);
intentcall.setData(Uri.parse("tel:" + phoneNumber));
this.startActivityForResult(intentcall, REQUEST_SLIPDROP_ICON_OFF);
然后像这样在电话监听器中设置结果:
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中的图标,但是什么也没有发生.
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;
哪里不对了?请指教!谢谢
解决方法:
我认为此操作不会返回结果,因此调用startActivityForResult与调用startActivity没什么不同
注意:输出=无.
http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL
标签:start-activity,onactivityresult,android 来源: https://codeday.me/bug/20191012/1901781.html