[英]onActivityResult not called
There are many question here from people having the exact same problem as I, and I've looked though a million, tried different things for 2-3 hours now, and I still can't get it working. 这里有许多问题来自与我有完全相同问题的人,我看了一百万,现在尝试了不同的东西2-3个小时,我仍然无法让它工作。
Child Activity: 儿童活动:
Intent resultIntent = new Intent(myColorPicker.this, WidgetConfig.class);
resultIntent.putExtra("key", appwidget_notecolor);
setResult(RESULT_OK, resultIntent);
finish();
Parent Activity: 家长活动:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Toast does not show
Toast.makeText(getApplicationContext(), "onActivityResult fired", Toast.LENGTH_SHORT).show();
if (resultCode == RESULT_OK ) {
// Toast does not show
Toast.makeText(getApplicationContext(), "Result Recieved", Toast.LENGTH_SHORT).show();
}
}
I launch child activity from parent activity like this: 我从父活动中启动子活动,如下所示:
Intent myColorPickerIntent = new Intent(WidgetConfig.this, myColorPicker.class);
myColorPickerIntent.putExtra("appwidget_notecolor", appwidget_notecolor);
WidgetConfig.this.startActivity(myColorPickerIntent);
当然你不会得到结果,你正在调用startActivity()而不是startActivityForResult()。
在创建Intent之后,您似乎没有调用startActivityForResult()。
你是否将意图传递给startActivityForResult()方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.