用户使用帐户和密码进行活动(登录屏幕)。我有一个活动正在设置屏幕(使用Webview),它取决于url(模型类Account具有loginId和状态)。
我有一个例子: account.me/u/mobile/menuloginId={loginId}&from=android&status={1/2}
如何修改URL,在登录帐户时在哪里修改URL?
班级设置屏幕中的某些代码:
public class B2BSettingController extends B2BViewController implements OnClickListener {
public B2BWebView mWebView = null;
public B2BDialogWindow<String> logoutDialog = null;
private B2BWebViewDataLoading mDataLoadingDialogView;
B2BSettingController(B2BMainActivity act, B2BHandler handler) {
super(act, handler);
}
@Override
public void displayContainView() {
turnTo(R.layout.b2b_setting, false, null, false);
}
@Override
public void initView(Map<String, Object> bundle) {
mDataLoadingDialogView = B2BWebViewDataLoading.getInstance(mActivity);
showOtherTitle(this);
B2BShowWitchButton btnStatus = new B2BShowWitchButton();
btnStatus.isShowLogoutButton = true;
showWhichButton(btnStatus);
setTitle(R.string.setting_ok);
mActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN |
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
mWebView = (B2BWebView) mView.findViewById(R.id.sv_setting);
mWebView.setTag(this);
mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.postUrl(MENU_PAGE, EncodingUtils.getBytes("loginId=" + B2BLoginBis.getUserLoginId()
+ "&contractType=" + B2BLoginBis.getUserContractType() + "&autoLoginKey="
+ B2BLoginBis.getUserAutoLoginKey() + "&lang=" + B2BApplication.getLanguage()
+ "&dpi=" + (mActivity.densityDpi >= 240 ? 1 : 0), "base64"));
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
if (errorCode == -2 && !mActivity.isDialogShowing()) {
mActivity.showMessageDialog(mActivity.getString(R.string.no_network_connection));
}
mDataLoadingDialogView.close();
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
mDataLoadingDialogView.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mDataLoadingDialogView.close();
}
});
}
谢谢!
答案 0 :(得分:0)
您可以使用shouldOverrideUrlLoading
的{{1}}方法来捕获重定向网址
WebViewClient