当从kotlin调用java活动结果时,onActivityResult不会被调用

我在我的项目中使用Kotlin和Java。 我打开Kotlin结果的Java活动,但写在Kotlin中的onActivityResult函数永远不会被调用。

代码(Kotlin):

  override fun viewAllNotes() { val intent : Intent = Intent(this, ViewAllNotesActivity::class.java) intent.putExtra(AppConstants.VIEW_ALL_FLOW, AppConstants.VIEW_ALL_NOTES_FLOW) startActivityForResult(intent, VIEW_ALL_REQUEST_CODE) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (resultCode == Activity.RESULT_OK){ if (requestCode == VIEW_ALL_REQUEST_CODE){ if (data!!.getParcelableArrayListExtra<ListNote>(AppConstants.NOTES_LIST)!=null){ mViewModel.mNotesReminders.listNote = data.getParcelableArrayListExtra(AppConstants.NOTES_LIST) } } } } 

代码(Java):

  @Override public void onBackPressed() { Intent result = new Intent(); result.putParcelableArrayListExtra(AppConstants.NOTES_LIST, mNotesList); setResult(Activity.RESULT_OK, result); this.finish(); } 

logcat的

 09-19 23:13:18.343 1552-1843/? I/ActivityManager: START u0 {cmp=com.raj.ifa.debug/com.raj.ifa.ui.viewAllNotesAndReminder.ViewAllNotesActivity (has extras)} from uid 10081 on display 0 09-19 23:13:18.383 28407-28407/com.raj.ifa.debug I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead. 09-19 23:13:18.607 28407-28412/com.raj.ifa.debug I/art: Do partial code cache collection, code=124KB, data=100KB 09-19 23:13:18.619 28407-28412/com.raj.ifa.debug I/art: After code cache collection, code=123KB, data=100KB 09-19 23:13:18.619 28407-28412/com.raj.ifa.debug I/art: Increasing code cache capacity to 512KB 09-19 23:13:18.792 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:18.823 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:18.858 1552-1572/? I/ActivityManager: Displayed com.raj.ifa.debug/com.raj.ifa.ui.viewAllNotesAndReminder.ViewAllNotesActivity: +500ms 09-19 23:13:18.863 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:18.880 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:18.925 28407-28407/com.raj.ifa.debug W/IInputConnectionWrapper: finishComposingText on inactive InputConnection 09-19 23:13:18.950 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:18.953 28407-28428/com.raj.ifa.debug D/OpenGLRenderer: endAllActiveAnimators on 0x8e89d080 (RippleDrawable) with handle 0x8e85d6c0 09-19 23:13:19.240 1552-22693/? I/WindowManager: Destroying surface Surface(name=com.raj.ifa.debug/com.raj.ifa.ui.userDetails.UserDetailsActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.WindowManagerService.tryStartExitingAnimation:3017 com.android.server.wm.WindowManagerService.relayoutWindow:2897 com.android.server.wm.Session.relayout:215 android.view.IWindowSession$Stub.onTransact:286 com.android.server.wm.Session.onTransact:136 09-19 23:13:21.707 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:21.767 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:21.800 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:21.831 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 09-19 23:13:21.834 28407-28428/com.raj.ifa.debug D/OpenGLRenderer: endAllActiveAnimators on 0x8ce94e80 (RippleDrawable) with handle 0x8e85d270 09-19 23:13:22.084 1552-14164/? I/WindowManager: Destroying surface Surface(name=com.raj.ifa.debug/com.raj.ifa.ui.viewAllNotesAndReminder.ViewAllNotesActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.removeLocked:1449 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2478 com.android.server.wm.WindowManagerService.removeWindowLocked:2436 com.android.server.wm.WindowManagerService.removeWindowLocked:2305 com.android.server.wm.WindowManagerService.removeWindow:2300 com.android.server.wm.Session.remove:193 09-19 23:13:22.261 28407-28428/com.raj.ifa.debug D/EGL_emulation: eglMakeCurrent: 0xa89852a0: ver 2 0 (tinfo 0xa8983630) 

谁能告诉我什么是我的上述代码错了?