Android许多嵌套活动问题
我有一个 Android 应用程序,其中有一个 ParentActivity 类,如下所示。
public class ParentActivity extends Activity {
protected void navigateForResult(Context c, Class<?> destination, int requestCode) {
Intent i = new Intent(c, destination);
startActivityForResult(i, requestCode);
}
}
我的所有其他活动都是从这个活动继承的。现在我有一个名为 CategoryListActivity 的活动,它继承自 ParentActivity。 CategoryListActivity 使用 ParentActivity 中名为 navigateForResult 的函数调用另一个名为 SubCategoryListActivity 的活动。
在 SubCategoryListActivity 中,我在某些事件中有以下代码,这些代码肯定会被触发。
...
setResult(Activity.RESULT_OK, resultIntent);
finishActivity(5);
我在 CategoryListActivity 中也有 onActivityResult 函数,但这不会被触发。我做错了什么吗?
I have an android application in which I have a ParentActivity class as follows.
public class ParentActivity extends Activity {
protected void navigateForResult(Context c, Class<?> destination, int requestCode) {
Intent i = new Intent(c, destination);
startActivityForResult(i, requestCode);
}
}
My all other activities are inherited from this activity. Now I have an activity called CategoryListActivity which is inherited from ParentActivity. The CategoryListActivity invokes another activity named SubCategoryListActivity using the function from ParentActivity named navigateForResult.
In SubCategoryListActivity I have following code in some event which is definitely fired.
...
setResult(Activity.RESULT_OK, resultIntent);
finishActivity(5);
I also have onActivityResult function in CategoryListActivity but this is not fired. Am I doing anything wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这个错误。 finishActivity(带有响应代码)实际上不起作用。我必须使用 finish() 代替
I figured out the bug. The finishActivity(with response code) doesn't really work. I have to use finish() instead