• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

load local html file in webview android studio

Hello
I converted a game from Cordova
After that I open the project on َAndroid Studio
I add WebView to my project in order to add Banner Ads

this my code:
----------------------------------
Code:
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // BannerPrapared();
    // enable Cordova apps to be started in the background
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
        moveTaskToBack(true);
    }

    // Set by <content src="index.html" /> in config.xml
    myWebView = (WebView) findViewById(R.id.webview);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    WebView myWebView = (WebView) findViewById(R.id.webview);
    BannerPrapared();
    //
    //
    // myWebView.loadUrl(launchUrl);
  myWebView.loadUrl("file:///android_asset/www/index.html");

----------------------------------------

The problem is that the game starts downloading and then celebrates

But when I put the link "https:// " of the game it works fine

I hope you get my idea

thanks
 
Last edited by a moderator:

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones