'How to Save login credentials like Username and Password in Webview
Currently, I am still in the process of learning Android development so please excuse me if this question of mine is not easily understandable for you.
I created an Android app of a website and that website has a login interface and i want to save the users data so they don't have to login every time. Now, is it possible to save user's Username and Password?
Since the setSavePassword method is deprecated, I can not find another way to implement saving Username and Password. I have read about SharedPreferences, JavaScript and Autofill several times, but I don't know how to properly implement them into my app. Because from most of what I have read, it is suggested that it will need a login page first to save the Username and Password.
This is my WebView code.
public class MainActivity extends AppCompatActivity {
private WebView mywebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mywebView = findViewById(R.id.webview);
mywebView.setWebViewClient(new WebViewClient());
mywebView.loadUrl("");
WebSettings webSettings = mywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
public static class mywebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
@Override
public void onBackPressed() {
if (mywebView.canGoBack()) {
mywebView.goBack();
} else {
super.onBackPressed();
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
