I'm creating a browser for android, but I'm having trouble running the url without the need for the protocol on the link, such as open www.google.com and the app automatically puts http: // to stay link and webeview recognize the link.
follow 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());
}
});
}
}