Skip to content

Work around dead activity issue in AppDetails

username-removed-22388 requested to merge mvdan/fdroidclient:fix-554 into master

It seems like install() sometimes runs when the AppDetails activity is finished or finishing. This results in the windows (dialogs) failing to show, and a BadTokenException to fire:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@d6e3570 is not valid; is your activity running?

This seems to be the culprit:

at org.fdroid.fdroid.AppDetails.install(AppDetails.java:840)
at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.install(AppDetails.java:1657)
at org.fdroid.fdroid.AppDetails$AppDetailsListFragment.onListItemClick(AppDetails.java:1721)

Apparently, you can check whether an activity/context is being finished:

https://stackoverflow.com/questions/7811993/error-binderproxy45d459c0-is-not-valid-is-your-activity-running

I cannot reproduce this issue, thus can't say whether this fixes it or not. Either way, it can't hurt to try. This can be reverted if we see ACRA reports of this in the future, and the issue reopened.

Fixes #565 (closed).

Merge request reports