Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
package com.example.mysite;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String Url = "https://mysite.com/";
webView = (WebView) findViewById(R.id.myweb);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(Url);
}
@Override
public void onBackPressed() {
if (webView.canGoBack()){
webView.goBack();
}
else
super.onBackPressed();
}
@Override
public void onPageFinished(WebView view, String Url) {
String javaScript ="javascript:(function() {var a= document.getElementsByClassName('bt_bb_port'); a[0].style.display='none'; })()";
webView.loadUrl(Url);
}
}