我想在从一个页面切换到另一个页面时显示警告消息。通过单击按钮,它应该加载目标页面。这是我的代码。我正在使用android studio 2.3.3。它不起作用。你能建议任何修改吗?谢谢你...
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.equals(Common_variables.BASE_URL + "s.changePswd.php")) {
AlertDialog.Builder b = new AlertDialog.Builder(Send_OTP.this);
b.setMessage("OTP has sent to your mail id");
b.setCancelable(true);
b.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent regIntent = new Intent(Send_OTP.this,Forgot_password.class);
startActivity(regIntent);
}
});
AlertDialog alert = b.create();
alert.show();
}
else
sendOTPwv.loadUrl(url);
return true;
}
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest
request)
{
if(request.getUrl().toString().equals(Common_variables.BASE_URL +
"s.changePswd.php"))
{
AlertDialog.Builder b = new AlertDialog.Builder(Send_OTP.this);
b.setMessage("OTP has sent to your mail id");
b.setCancelable(true);
b.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent regIntent = new Intent(Send_OTP.this,Forgot_password.class);
startActivity(regIntent);
}
});
AlertDialog alert = b.create();
alert.show();
}
else
sendOTPwv.loadUrl(request.getUrl().toString());
return true;
}
}
}
请建议我必须在代码中进行更改。