取消后,startActivityForResult中的startActivityForResult返回mainActivity

时间:2015-07-31 07:29:43

标签: android android-intent android-activity

如果我取消QR码扫描,我有一个它调用startActivityForResult的MainActivity,并且该活动调用startActivityForResult(QR码扫描)。

结束
protected void onActivityResult(int requestCode, int resultCode, Intent data)

在主活动中不在第一个startActivityForResult中,好像第一个startActivityForResult已经以某种方式退出,如果我扫描代码我在第一个startActivityForResult中正确得到结果

为什么会发生这种情况的任何想法?

07-31 08:49:07.640: E/WindowManager(22584): Activity com.deufol.lbproduction.activities.OrderListActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41897bd0 that was originally added here
07-31 08:49:07.640: E/WindowManager(22584): android.view.WindowLeaked: Activity com.deufol.lbproduction.activities.OrderListActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41897bd0 that was originally added here
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:374)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.Window$LocalWindowManager.addView(Window.java:559)
07-31 08:49:07.640: E/WindowManager(22584):     at android.app.Dialog.show(Dialog.java:277)
07-31 08:49:07.640: E/WindowManager(22584):     at android.app.ProgressDialog.show(ProgressDialog.java:116)
07-31 08:49:07.640: E/WindowManager(22584):     at android.app.ProgressDialog.show(ProgressDialog.java:104)
07-31 08:49:07.640: E/WindowManager(22584):     at com.deufol.lbproduction.activities.OrderListActivity.startQRScanIntetnt(OrderListActivity.java:533)
07-31 08:49:07.640: E/WindowManager(22584):     at com.deufol.lbproduction.activities.OrderListActivity.onOptionsItemSelected(OrderListActivity.java:166)
07-31 08:49:07.640: E/WindowManager(22584):     at android.app.Activity.onMenuItemSelected(Activity.java:2605)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:958)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:514)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:99)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.View.performClick(View.java:4084)
07-31 08:49:07.640: E/WindowManager(22584):     at android.view.View$PerformClick.run(View.java:16966)
07-31 08:49:07.640: E/WindowManager(22584):     at android.os.Handler.handleCallback(Handler.java:615)
07-31 08:49:07.640: E/WindowManager(22584):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-31 08:49:07.640: E/WindowManager(22584):     at android.os.Looper.loop(Looper.java:137)
07-31 08:49:07.640: E/WindowManager(22584):     at android.app.ActivityThread.main(ActivityThread.java:4746)
07-31 08:49:07.640: E/WindowManager(22584):     at java.lang.reflect.Method.invokeNative(Native Method)
07-31 08:49:07.640: E/WindowManager(22584):     at java.lang.reflect.Method.invoke(Method.java:511)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:917)
07-31 08:49:07.640: E/WindowManager(22584):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
07-31 08:49:07.640: E/WindowManager(22584):     at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

在阅读日志时,您似乎尝试在取消扫描时退出ProgressDialog中的Activity。第533行和/或第116行会发生什么?

07-31 08:49:07.640: E/WindowManager(22584):     at com.deufol.lbproduction.activities.OrderListActivity.startQRScanIntetnt(OrderListActivity.java:533)
07-31 08:49:07.640: E/WindowManager(22584):     at com.deufol.lbproduction.activities.OrderListActivity.onOptionsItemSelected(OrderListActivity.java:166)

Here is a similar question。建议您在扫描活动中的dismiss()上致电ProgressDialog。例如,覆盖扫描活动中的onBackPressed()方法并取消任何对话框。