0

I have the MainActivity it calls startActivityForResult and that activity calls startActivityForResult (QR code scanning), if i cancel the QR code scanning. I end in the

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

in the main activity not in the first startActivityForResult as if the first startActivityForResult has exited somehow, if i scann the code i get the result correctly in the first startActivityForResult

any ideas why this should happen?

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)
Roman Ryba
  • 53
  • 9

1 Answers1

0

From reading the log it seems you try to start a ProgressDialog in the Activity you exit when you cancel the scan. What happens at line 533 and/or 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. It is suggested you call dismiss() on the ProgressDialog you have in the scanning activity. For example, override the onBackPressed() method in your scanning activity and dismis any dialogs.

Community
  • 1
  • 1
milez
  • 2,201
  • 12
  • 31
  • yes in the startQRScanIntetnt is ProgressDialog. i tryied to remove it from the code , it stoped returning the error in LogCat but still returns me to the Main activity after cancel the scanning – Roman Ryba Jul 31 '15 at 07:56
  • I guess if you cancel with back button it destroys the QR activity and returns to MainActivity. You could override onBackPress and call setResult(int) there if you have no other scenario where it gets called if you cancel. – milez Jul 31 '15 at 08:07
  • it does not seen to have any effect , it does close the first startActivityForResult even if i cancel the selection off instaled Apps which should handle the QR scanning , it is realy wierd – Roman Ryba Jul 31 '15 at 08:38
  • Do you have "Don't keep activities" on in the developer options? If yes, turn it off. – milez Jul 31 '15 at 08:50
  • It is turned off, i have added breakpoint on onDestroy() in the first startActivityForResult and its called after the onActivityResult in the main activity ... – Roman Ryba Jul 31 '15 at 09:54
  • Sounds so weird that you would have to post a lot of code for anyone here to solve that problem. – milez Jul 31 '15 at 09:55