• 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

netgoogle

Lurker
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:
I moved this to the dev area for better exposure. I also added code tags for readability. :)

[code]Line1
Line2
Line3
...
...
...
...LineX
[/code]
Code:
Line1
Line2
Line3
...
...
...
...LineX
 
Back
Top