0
I’m making a web app with just one nick login.
Every time someone opens the app, they only enter the variable url
where the page asks for the nickname, but I wanted it to save the last URL to access it the next time the user opens the app, and if there is no saved URL, it opens the default URL. So the user doesn’t have to type his nickname every time.
This is my current code:
public class MainActivity extends AppCompatActivity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide(); //Escconde TopBar
setContentView(R.layout.activity_main);
//Declanação variavel url
String url = "http://endereçodomeusiteapp";
String eror = "Sem erro";
webView = (WebView) findViewById(R.id.webview);
//Habilita javaScript
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
//Url Padrão.
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient(){
public void onReceivedError(WebView view, int eror, String description, String html) {
webView.loadUrl("file:///android_asset/conex.html");
}});
Thank you very much friend, God bless you. It worked perfectly, I am very grateful for your help.
– Leônidas Roberto
I am very grateful to see that I was able to help you. Hug!
– Ivan Silva