0
I’m creating a browser for android, but I’m having trouble running the url without the need for the protocol on the link like opening www.google.com and the app automatically put http:// to stay http://www.google.com and the webeview recognize the link.
follows below my mainactivity
public class MainActivity extends AppCompatActivity {
//definir na programação ---
private android.widget.Button botaoNav;
private android.widget.EditText urlNav;
private android.webkit.WebView navegadorNav;
//---
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// achar oque cada variavel é, nome do elemento no FindViewById
botaoNav = (android.widget.Button) findViewById(R.id.botaoPesquisar);
urlNav = (android.widget.EditText) findViewById(R.id.urlPesquisar);
navegadorNav = (android.webkit.WebView) findViewById(R.id.navegador);
//definir java script
navegadorNav.getSettings().setJavaScriptEnabled(true);
//definir app como navegador
navegadorNav.setWebViewClient(new android.webkit.WebViewClient());
//Ação pesquisar
botaoNav.setOnClickListener(new android.view.View.OnClickListener(){
@Override
//carregar url
public void onClick(android.view.View v){
navegadorNav.loadUrl(urlNav.getText().toString());
}
});
}
}
As I understand it, the user type the link and the webview goes to him, is that it? If it is, just concatenate the string, boot
navegadorNav.loadUrl("https://" + urlNav.getText().toString());
– Woton Sampaio