We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
背景: 目前我们的应用使用插件化进行开发, 将 feedback 作为单独的一个应用开发完毕后植入宿主的插件管理器中.
现状: MainActivity 负责实例化 Feedback 相关 fragment 并展示后, 如果用户进入二级页面时误触返回键, 会导致 Activity 被关闭, 而不是返回一级页面.
诉求: 提供相关接口用于管理 WebView 的导航.
workaround: 使用反射获取 WebView, 在 onBackPressed() 回调中对 webView 进行状态判断.
The text was updated successfully, but these errors were encountered:
Workaround used:
@Override public void onBackPressed() { if (webView == null && fragment != null) { // 通过反射获取 WebView 对象, 以便管理导航 Field[] fields = fragment.getClass().getDeclaredFields(); for (Field field : fields) { if (WebView.class.isAssignableFrom(field.getType())) { field.setAccessible(true); try { webView = (WebView) field.get(fragment); } catch (IllegalAccessException ignore) { // never } break; } } } if (webView == null) { super.onBackPressed(); } else { if (webView.canGoBack()) { webView.goBack(); if (url == null) { url = webView.getUrl(); } else { // webView 退到最后一页时, 协助关闭页面 if (url.equals(webView.getUrl())) { super.onBackPressed(); } else { url = webView.getUrl(); } } } else { super.onBackPressed(); } } }
Sorry, something went wrong.
No branches or pull requests
背景: 目前我们的应用使用插件化进行开发, 将 feedback 作为单独的一个应用开发完毕后植入宿主的插件管理器中.
现状: MainActivity 负责实例化 Feedback 相关 fragment 并展示后, 如果用户进入二级页面时误触返回键, 会导致 Activity 被关闭, 而不是返回一级页面.
诉求: 提供相关接口用于管理 WebView 的导航.
workaround: 使用反射获取 WebView, 在 onBackPressed() 回调中对 webView 进行状态判断.
The text was updated successfully, but these errors were encountered: