Guten Tag an alle bekommen,Wie alle URL WebView in android Studio
Ich bin eine einfache Anwendung zu machen (zu Übungszwecken), die eine WebView in Android Studio verwendet. Ich möchte, dass meine App auf alle URLs stößt, die ich eingib. Ex, Wenn ich Facebook öffne, stößt es auf seine URL an und wenn ich mich in meinem Konto anmelde, wird es wieder meinen Facebook-Account anstoßen, klingt so. Hier ist mein Code. Ich bin neu in Sache Sache, irgendwelche Vorschläge oder Hilfe werden sehr geschätzt. Ich danke dir sehr.
xml Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.nevigrof.ymuc.Back_order">
<WebView
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:id="@+id/webview1"/>
</RelativeLayout>
Java Codes
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_survey_form);
webview = (WebView) findViewById(R.id.webview1);
webview.setWebViewClient(new MyWebViewClient());
openURL();
}
private void openURL() {
webview.requestFocus(View.FOCUS_DOWN | View.FOCUS_UP);
webview.loadUrl("http:/https://www.facebook.com/");
webview.getSettings().setJavaScriptEnabled(true);
String webUrl = webview.getUrl();
Toast.makeText(Back_order.this, webUrl, Toast.LENGTH_LONG).show();
}
}
Es ist ein Tippfehler in der URL an webview.loadUrl() – jomartigcal