简体   繁体   中英

Android Studio WebView only displaying white screen

Hi everyone I have this activity which display this link that I'm trying to embed, but it only display a blank white screen. It doesn't show any errors. I also tried links like googe.com and it loads just fine.

Here's my code:


import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.drawerlayout.widget.DrawerLayout;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.google.android.material.navigation.NavigationView;

public class BarangayMap extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

    WebView BarangayWebView;
    DrawerLayout drawerLayout;
    androidx.appcompat.widget.Toolbar toolbar;
    NavigationView navigationView;
    ActionBarDrawerToggle actionBarDrawerToggle;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_barangay_map);

        drawerLayout = (DrawerLayout) findViewById(R.id.drawer);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        navigationView = (NavigationView) findViewById(R.id.navigation);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,toolbar,R.string.drawerOpen,R.string.drawerClose);

        drawerLayout.addDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();
        navigationView.setNavigationItemSelectedListener(this);

        BarangayWebView = (WebView) findViewById(R.id.barangay_view);

        WebSettings webSettings = BarangayWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        BarangayWebView.setWebViewClient(new WebViewClient());
        BarangayWebView.loadUrl("universityofmind.maps.arcgis.com/apps/Embed/index.html?webmap=a76ed45e315d48d38d59f8a989d0c592&extent=124.9283,7.054,126.3648,7.8043&home=true&zoom=true&previewImage=false&scale=true&basemap_gallery=true&disable_scroll=false&theme=light"); 
    }



    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
        switch (menuItem.getItemId()){
            case R.id.nav_legend:
                Toast.makeText(BarangayMap.this, "show legend", Toast.LENGTH_SHORT).show();
                break;

            case R.id.nav_about:
                Toast.makeText(BarangayMap.this, "show about", Toast.LENGTH_SHORT).show();
                break;

            case R.id.nav_addTag:
                Intent i = new Intent(getApplicationContext(), StepsActivity.class);
                startActivity(i);
                break;
        }

        return false;
    }


}

I've also attached a screenshot of the display on my screen HERE

How do I solve this? I'm new to android so sorry for the messy code

请在您的网址前添加 http://,如下所示

ww_view.loadUrl("http://universityofmind.maps.arcgis.com/apps/Embed/index.html?webmap=a76ed45e315d48d38d59f8a989d0c592&extent=124.9283,7.054,126.3648,7.8043&home=true&zoom=true&previewImage=false&scale=true&basemap_gallery=true&disable_scroll=false&theme=light");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM