@Override
            public void run() {
                Activity activity = getForegroundActivity(context);
                if (activity != null) {
                    showToast(activity, message);
                } else {
                    if (remainingAttempts > 0) {
                        showToastWhenPossible(context, message, remainingAttempts - 1);
                    }
                }
            }
Show a toast when an activity becomes available (if possible).
freeline-runtime/src/main/java/com/antfortune/freeline/util/Restarter.java