我使用webl通过使用url formant访问具有http身份验证的网站: http://username:password@url.com。在一些4.4设备上我登录了其他一些豆粕,我不是。我能做什么? p.S。:我无法在avd管理器中选择较旧的目标sdk,尽管我下载了一些
public class Main extends Activity {
WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Bundle icicle = null;
super.onCreate(icicle);
setContentView(R.layout.main);
//SharedPreferences prefs = getPreferences(MODE_PRIVATE);
//String restoredText = prefs.getString("text", null);
//if (restoredText != null)
//{
//mSaved.setText(restoredText, TextView.BufferType.EDITABLE);
//long name = prefs.getLong("name", -1);
//long pw = prefs.getLong("pw", -1);
/*if (selectionStart != -1 && selectionEnd != -1)
{
mSaved.setSelection(selectionStart, selectionEnd);
}*/
//}
//-----------------------------------------------------------------------
mWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(true);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
// mWebView.setHttpAuthUsernamePassword(url", "", "usr", "pw");
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}});
mWebView.loadUrl("//here url stuff");
//return false;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main, menu);
MenuInflater inflater1 = getMenuInflater();
inflater1.inflate(R.menu.reload, menu);
return true;
}
final class DemoJavaScriptInterface {
DemoJavaScriptInterface() {
}
public void clickOnAndroid() {
Handler mHandler = null;
mHandler.post(new Runnable() {
public void run() {
mWebView.loadUrl("javascript:wave()");
}
});
}
}
//chrome
final class MyWebChromeClient extends WebChromeClient {
private final String LOG_TAG = null;
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
Log.d(LOG_TAG, message);
result.confirm();
return true;
}
}
答案 0 :(得分:0)
首先,您不需要在onCreateOptions菜单中更好地将setContentView移动到onCreate metot
您是否检查过logcat,可能是因为您正在尝试在onCreateOptionsMenu方法中执行某些请求{/ 1}