Example usage for android.webkit WebView loadUrl

List of usage examples for android.webkit WebView loadUrl

Introduction

In this page you can find the example usage for android.webkit WebView loadUrl.

Prototype

public void loadUrl(String url) 

Source Link

Document

Loads the given URL.

Usage

From source file:com.ezac.gliderlogs.FlightWeatherActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        appLND = extras.getString("Ref");
    }/*from  www  .j  a  v  a  2s  .c o m*/
    setContentView(R.layout.weather_list);
    // hide soft keyboard
    setMode();
    // disable these fields, these are output only
    nameText = (EditText) findViewById(R.id.editText61);
    nameText.setClickable(false);
    nameText.setFocusable(false);
    rainText = (EditText) findViewById(R.id.editText61a);
    rainText.setClickable(false);
    rainText.setFocusable(false);
    windText = (EditText) findViewById(R.id.editText62);
    windText.setClickable(false);
    windText.setFocusable(false);
    wdpkText = (EditText) findViewById(R.id.editText62a);
    wdpkText.setClickable(false);
    wdpkText.setFocusable(false);
    presText = (EditText) findViewById(R.id.editText63);
    presText.setClickable(false);
    presText.setFocusable(false);
    humiText = (EditText) findViewById(R.id.editText64);
    humiText.setClickable(false);
    humiText.setFocusable(false);
    wdgrText = (EditText) findViewById(R.id.editText65);
    wdgrText.setClickable(false);
    wdgrText.setFocusable(false);
    wdirText = (EditText) findViewById(R.id.editText66);
    wdirText.setClickable(false);
    wdirText.setFocusable(false);
    tempText = (EditText) findViewById(R.id.editText67);
    tempText.setClickable(false);
    tempText.setFocusable(false);
    wolkText = (EditText) findViewById(R.id.editText67a);
    wolkText.setClickable(false);
    wolkText.setFocusable(false);
    sunuText = (EditText) findViewById(R.id.editText68);
    sunuText.setClickable(false);
    sunuText.setFocusable(false);
    sundText = (EditText) findViewById(R.id.editText69);
    sundText.setClickable(false);
    sundText.setFocusable(false);
    mtr1Text = (EditText) findViewById(R.id.editText70);
    mtr1Text.setClickable(false);
    mtr1Text.setFocusable(false);
    mtr2Text = (EditText) findViewById(R.id.editText71);
    mtr2Text.setClickable(false);
    mtr2Text.setFocusable(false);
    knmiText = (EditText) findViewById(R.id.editText81);
    knmiText.setClickable(false);
    knmiText.setFocusable(false);

    Button close = (Button) findViewById(R.id.button_close);
    WebView browser = (WebView) findViewById(R.id.webview_1);

    browser.getSettings().setLoadsImagesAutomatically(true);
    // browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    //browser.loadUrl("http://www.buienradar.nl/images.aspx?jaar=-3&soort=sp-loop");
    browser.loadUrl("http://api.buienradar.nl/image/1.0/RadarMapBE?w=500&h=512");

    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
        }
    });

    new NET1_Task().execute("http://xml.buienradar.nl", "1;" + FlightOverviewActivity.appMST);
    String s[] = FlightOverviewActivity.appMTR.split(";");
    new NET1_Task().execute("http://aviationweather.gov/adds/dataserver_current/httpparam?"
            + "dataSource=metars&requestType=retrieve&format=xml&stationString=EHFS&"
            + "hoursBeforeNow=3&mostRecent=true", "2;" + s[0]);
    new NET1_Task().execute("http://aviationweather.gov/adds/dataserver_current/httpparam?"
            + "dataSource=metars&requestType=retrieve&format=xml&stationString=EHWO&"
            + "hoursBeforeNow=3&mostRecent=true", "3;" + s[1]);
    new NET2_Task().execute("http://www.knmi.nl/waarschuwingen_en_verwachtingen/luchtvaart/"
            + "weerbulletin_kleine_luchtvaart.html", "4;0");
}

From source file:com.ezac.gliderlogs.FlightADSBActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//from  ww  w.  j av  a2  s . c o  m

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://86.83.189.66:8099//gmap.php");
}

From source file:com.ezac.gliderlogs.FlightGliderActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//ww w  . j  a va2 s.  c om

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://live.glidertracking.com/index.php");
}

From source file:com.ezac.gliderlogs.FlightOGNActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.view_list);//from   w w  w  . j  a  v a 2  s  .  c o m

    // hide soft keyboard
    setMode();

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://live.glidernet.org/#c=51.27405,3.93909&z=11");
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetSettingsAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    /* TODO: This definitely needs some huge refactoring
     *//*from w  ww.j  a  v a2  s  .  co  m*/
    final int pos = position;

    RelativeLayout widgetView;
    TextView labelTextView;
    ImageView roomEditView;
    int widgetLayout = 0;
    OpenHABWidget openHABWidget = getItem(position);
    switch (this.getItemViewType(position)) {
    case TYPE_FRAME:
        widgetLayout = R.layout.openhabwidgetlist_frameitem;
        break;
    case TYPE_GROUP:
        widgetLayout = R.layout.openhabwidget_settings_item;
        break;

    case TYPE_IMAGE:
        widgetLayout = R.layout.openhabwidgetlist_imageitem;
        break;

    case TYPE_CHART:
        widgetLayout = R.layout.openhabwidgetlist_chartitem;
        break;
    case TYPE_VIDEO:
        widgetLayout = R.layout.openhabwidgetlist_videoitem;
        break;
    case TYPE_WEB:
        widgetLayout = R.layout.openhabwidgetlist_webitem;
        break;
    default:
        widgetLayout = R.layout.openhabwidget_settings_item;
        break;
    }
    if (convertView == null) {
        widgetView = new RelativeLayout(getContext());
        String inflater = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater vi;
        vi = (LayoutInflater) getContext().getSystemService(inflater);
        vi.inflate(widgetLayout, widgetView, true);
    } else {
        widgetView = (RelativeLayout) convertView;
    }
    switch (getItemViewType(position)) {
    case TYPE_FRAME:
        labelTextView = (TextView) widgetView.findViewById(R.id.framelabel);
        if (labelTextView != null)
            labelTextView.setText(openHABWidget.getLabel());
        widgetView.setClickable(false);
        if (openHABWidget.getLabel().length() > 0) { // hide empty frames
            widgetView.setVisibility(View.VISIBLE);
            labelTextView.setVisibility(View.VISIBLE);
        } else {
            widgetView.setVisibility(View.GONE);
            labelTextView.setVisibility(View.GONE);
        }
        break;
    case TYPE_IMAGE:
        MySmartImageView imageImage = (MySmartImageView) widgetView.findViewById(R.id.imageimage);
        imageImage.setImageUrl(ensureAbsoluteURL(openHABBaseUrl, openHABWidget.getUrl()), false);
        if (openHABWidget.getRefresh() > 0) {
            imageImage.setRefreshRate(openHABWidget.getRefresh());
            refreshImageList.add(imageImage);
        }
        break;
    case TYPE_CHART:
        MySmartImageView chartImage = (MySmartImageView) widgetView.findViewById(R.id.chartimage);
        OpenHABItem chartItem = openHABWidget.getItem();
        Random random = new Random();
        String chartUrl = "";
        if (chartItem.getType().equals("GroupItem")) {
            chartUrl = openHABBaseUrl + "rrdchart.png?groups=" + chartItem.getName() + "&period="
                    + openHABWidget.getPeriod() + "&random=" + String.valueOf(random.nextInt());
        }
        Log.i("OpenHABWidgetAdapter", "Chart url = " + chartUrl);
        chartImage.setImageUrl(chartUrl, false);
        // TODO: This is quite dirty fix to make charts look full screen width on all displays
        ViewGroup.LayoutParams chartLayoutParams = chartImage.getLayoutParams();
        int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getWidth();
        chartLayoutParams.height = (int) (screenWidth / 1.88);
        chartImage.setLayoutParams(chartLayoutParams);
        if (openHABWidget.getRefresh() > 0) {
            chartImage.setRefreshRate(openHABWidget.getRefresh());
            refreshImageList.add(chartImage);
        }
        Log.i("OpenHABWidgetAdapter",
                "chart size = " + chartLayoutParams.width + " " + chartLayoutParams.height);
        break;
    case TYPE_VIDEO:
        VideoView videoVideo = (VideoView) widgetView.findViewById(R.id.videovideo);
        Log.i("OpenHABWidgetAdapter", "Opening video at " + openHABWidget.getUrl());
        // TODO: This is quite dirty fix to make video look maximum available size on all screens
        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams();
        videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77);
        videoVideo.setLayoutParams(videoLayoutParams);
        // We don't have any event handler to know if the VideoView is on the screen
        // so we manage an array of all videos to stop them when user leaves the page
        if (!videoWidgetList.contains(videoVideo))
            videoWidgetList.add(videoVideo);
        // Start video
        if (!videoVideo.isPlaying()) {
            videoVideo.setVideoURI(Uri.parse(openHABWidget.getUrl()));
            videoVideo.start();
        }
        Log.i("OpenHABWidgetAdapter", "Video height is " + videoVideo.getHeight());
        break;
    case TYPE_WEB:
        WebView webWeb = (WebView) widgetView.findViewById(R.id.webweb);
        if (openHABWidget.getHeight() > 0) {
            ViewGroup.LayoutParams webLayoutParams = webWeb.getLayoutParams();
            webLayoutParams.height = openHABWidget.getHeight() * 80;
            webWeb.setLayoutParams(webLayoutParams);
        }
        webWeb.setWebViewClient(new WebViewClient());
        webWeb.loadUrl(openHABWidget.getUrl());
        break;

    default:
        labelTextView = (TextView) widgetView.findViewById(R.id.itemlabel);
        roomEditView = (ImageView) widgetView.findViewById(R.id.editimg);
        if (null != roomEditView) {
            roomEditView.setVisibility(View.VISIBLE);
            roomEditView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    if (null != listItemListener)
                        listItemListener.onEditClickListener(pos);
                }
            });
        }
        if (labelTextView != null)
            labelTextView.setText(openHABWidget.getLabel());
        MySmartImageView sliderImage = (MySmartImageView) widgetView.findViewById(R.id.itemimage);
        sliderImage.setImageUrl(openHABBaseUrl + "images/" + openHABWidget.getIcon() + ".png");
        break;
    }
    LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider);
    if (dividerLayout != null) {
        if (position < this.getCount() - 1) {
            if (this.getItemViewType(position + 1) == TYPE_FRAME) {
                dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets
            } else {
                dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others
            }
        } else { // last widget in the list, hide divider
            dividerLayout.setVisibility(View.GONE);
        }
    }
    return widgetView;
}

From source file:com.pursuer.reader.easyrss.WebpageItemViewCtrl.java

@SuppressLint("SetJavaScriptEnabled")
public WebpageItemViewCtrl(final DataMgr dataMgr, final Context context, final String uid,
        final boolean isMobilized) {
    super(dataMgr, R.layout.webpage_item, context);

    this.item = dataMgr.getItemByUid(uid, ITEM_PROJECTION);
    this.theme = new SettingTheme(dataMgr).getData();
    this.fontSize = new SettingFontSize(dataMgr).getData();
    // Disable hardware acceleration on Android 3.0-4.1 devices.
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
            && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }//from  w  ww  .ja va  2 s  . c  om

    {
        mobilizedView = (WebView) view.findViewById(R.id.MobilizedContent);
        mobilizedView.setBackgroundColor(context.getResources().getColor(
                theme == SettingTheme.THEME_NORMAL ? R.color.NormalBackground : R.color.DarkBackground));
        mobilizedView.setFocusable(false);
        final WebSettings settings = mobilizedView.getSettings();
        settings.setDefaultTextEncodingName(HTTP.UTF_8);
        settings.setJavaScriptEnabled(false);
        settings.setDefaultFontSize(fontSize);
    }
    {
        originalView = (WebView) view.findViewById(R.id.OriginalContent);
        originalView.setFocusable(false);
        originalView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        final WebSettings settings = originalView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        originalView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(final WebView webView, final String url) {
                view.findViewById(R.id.OriginalProgress).setVisibility(View.GONE);
            }

            @Override
            public void onPageStarted(final WebView webView, final String url, final Bitmap favicon) {
                if (!showMobilized) {
                    view.findViewById(R.id.OriginalProgress).setVisibility(View.VISIBLE);
                }
            }

            @Override
            public boolean shouldOverrideUrlLoading(final WebView webView, final String url) {
                webView.loadUrl(url);
                return false;
            }
        });
    }

    if (isMobilized) {
        showMobilizedPage();
    } else {
        showOriginalPage();
    }

    view.findViewById(R.id.BtnMobilzedPage).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            showMobilizedPage();
        }
    });
    view.findViewById(R.id.BtnOriginalPage).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            showOriginalPage();
        }
    });
    view.findViewById(R.id.BtnClose).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            if (listener != null) {
                listener.onBackNeeded();
            }
        }
    });
}

From source file:com.zhongyun.viewer.cameralist.CameraListActivity.java

private void showDisclaimerDlg() {
    if (null != mDisclaimerDialog) {
        mDisclaimerDialog.show();/*from   w w  w  . jav a2s.co m*/
    } else {
        WebView webView = new WebView(CameraListActivity.this);
        webView.loadUrl(mShowChinese ? DISCLAIMER_URL_CN : DISCLAIMER_URL_EN);
        mDisclaimerDialog = new AlertDialog.Builder(this).setView(webView).setTitle(R.string.disclaimer)
                .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).create();
        mDisclaimerDialog.show();
    }
}

From source file:com.ezac.gliderlogs.FlightEzacActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.ezac_list);//  www  .  j ava  2 s. com

    // hide soft keyboard
    setMode();

    Button close = (Button) findViewById(R.id.button_close);

    WebView browser = (WebView) findViewById(R.id.webview_1);
    browser.setWebViewClient(new WebViewClient());
    browser.getSettings().setSupportZoom(true);
    browser.getSettings().setBuiltInZoomControls(true);
    browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    browser.setScrollbarFadingEnabled(true);
    browser.getSettings().setLoadsImagesAutomatically(true);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024 * 1024 * 32);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    browser.getSettings().setAppCachePath(appCachePath);
    browser.getSettings().setAllowFileAccess(true);
    browser.getSettings().setJavaScriptEnabled(true);
    browser.loadUrl("http://www.ezac.nl/drupal/");

    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setResult(RESULT_OK);
            finish();
        }
    });
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

private void showHelpDialog() {
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.trigger_loc_maps_tips);
    dialog.setTitle(R.string.trigger_loc_defining_locations);
    dialog.setOwnerActivity(this);
    dialog.show();/*ww  w. j  av a 2 s.  c o m*/

    WebView webView = (WebView) dialog.findViewById(R.id.web_view);
    webView.loadUrl("file:///android_res/raw/trigger_loc_maps_help.html");

    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.check_do_not_show);
    checkBox.setChecked(shouldSkipToolTip());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            SharedPreferences pref = LocTrigMapsActivity.this.getSharedPreferences(TOOL_TIP_PREF_NAME,
                    Context.MODE_PRIVATE);

            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean(KEY_TOOL_TIP_DO_NT_SHOW, isChecked);
            editor.commit();
        }
    });

    Button button = (Button) dialog.findViewById(R.id.button_close);
    button.setTag(dialog);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Object tag = v.getTag();
            if (tag != null && tag instanceof Dialog) {
                ((Dialog) tag).dismiss();
            }
        }
    });
}

From source file:ph.com.globe.connect.AuthenticationActivity.java

/**
 * On activity create process.//from   www . j ava  2 s.c om
 *
 * @param savedInstanceState instance state
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    // call base create
    super.onCreate(savedInstanceState);

    // initialize web view
    final WebView webview = new WebView(this);

    // set content view of the activity
    setContentView(webview);

    // get the app id from intent
    final String appId = getIntent().getStringExtra("app_id");
    // get the app secret from intent
    final String appSecret = getIntent().getStringExtra("app_secret");

    // set web view client
    webview.setWebViewClient(new WebViewClient() {
        /**
         * Let's catch all url changes.
         *
         * @param view current view
         * @param url current url
         * @return boolean
         */
        @SuppressWarnings("deprecation")
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // parse the uri
            final Uri uri = Uri.parse(url);

            // are we still on globe labs?
            if (uri.toString().indexOf(ROOT_URL) != 0) {
                // get the code
                String code = uri.getQueryParameter("code");

                // get access token request
                try {
                    getAccessToken(appId, appSecret, code);
                } catch (ApiException | HttpRequestException e) {
                    e.printStackTrace();
                }

                return false;
            }

            // load uri
            view.loadUrl(uri.toString());

            return false;
        }

        /**
         * Let's catch all url changes.
         *
         * @param view current view
         * @param request web resource request
         * @return boolean
         */
        @TargetApi(Build.VERSION_CODES.N)
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            // parse the uri
            final Uri uri = Uri.parse(request.getUrl().toString());

            // are we still on globe labs?
            if (uri.toString().indexOf(ROOT_URL) != 0) {
                // get the code
                String code = uri.getQueryParameter("code");

                // get access token request
                try {
                    getAccessToken(appId, appSecret, code);
                } catch (ApiException | HttpRequestException e) {
                    e.printStackTrace();
                }

                return false;
            }

            // load uri
            view.loadUrl(uri.toString());

            return false;
        }
    });

    try {
        // set dialog url
        String DIALOG_URL = this.buildUrl(this.DIALOG_URL, appId);

        // load the url
        webview.loadUrl(DIALOG_URL);
    } catch (ApiException e) {
        e.printStackTrace();
    }
}