List of usage examples for android.webkit WebView loadUrl
public void loadUrl(String url)
From source file:com.z299studio.pb.ActionDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (Application.getInstance() == null || Application.getInstance().getAccountManager() == null) { return null; }// w ww .jav a 2 s .c o m View rootView; int[] layouts = { R.layout.dialog_authenticate, R.layout.dialog_export, R.layout.dialog_import, R.layout.dialog_reset_pwd, R.layout.dialog_credits, R.layout.dialog_license, R.layout.dialog_authenticate }; rootView = inflater.inflate(layouts[mDlgType], container, false); mOkButton = (Button) rootView.findViewById(R.id.ok); if (mOkButton != null) { mOkButton.setOnClickListener(this); } View cancel = rootView.findViewById(R.id.cancel); if (cancel != null) { cancel.setOnClickListener(this); } if (mDlgType != ACTION_EXPORT && mOkButton != null) { mOkButton.setEnabled(false); mOkButton.setAlpha(0.4f); } switch (mDlgType) { case ACTION_EXPORT: case ACTION_IMPORT: Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner); ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(), mDlgType == ACTION_EXPORT ? R.array.file_types : R.array.file_types_import, android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(mFileType); spinner.setOnItemSelectedListener(this); if (mDlgType == ACTION_IMPORT) { int ids[] = { R.id.ignore, R.id.keepall, R.id.overwrite }; for (int i = 0; i < ids.length; ++i) { RadioButton rb = (RadioButton) rootView.findViewById(ids[i]); rb.setOnClickListener(this); if (i == mOption) { rb.setChecked(true); } } mSelectButton = (Button) rootView.findViewById(R.id.select); mSelectButton.setOnClickListener(this); } break; case ACTION_AUTHENTICATE2: ((TextView) rootView.findViewById(R.id.auth_desc)).setText(R.string.diff_pwd); ((Button) rootView.findViewById(R.id.cancel)).setText(R.string.discard); // no break to use the logic of authenticate case ACTION_AUTHENTICATE: mPasswordEdits[1] = (EditText) rootView.findViewById(R.id.et_password); mPasswordEdits[1].addTextChangedListener(this); break; case ACTION_RESET_PWD: int ids[] = { R.id.et_cur_pwd, R.id.et_password, R.id.et_confirm }; for (int i = 0; i < ids.length; ++i) { mPasswordEdits[i] = (EditText) rootView.findViewById(ids[i]); mPasswordEdits[i].addTextChangedListener(this); } break; case ACTION_CREDITS: rootView.findViewById(R.id.cancel).setOnClickListener(this); TextView tv = (TextView) rootView.findViewById(R.id.testers); tv.setText(R.string.cc_yhc); tv = (TextView) rootView.findViewById(R.id.translators); String translators = String.format(Locale.getDefault(), "%s: %s\n%s: %s\n%s: %s", getString(R.string.lang_fr), getString(R.string.cc_xcx), getString(R.string.lang_es), getString(R.string.cc_jh), getString(R.string.lang_zhtw), getString(R.string.cc_qqz)); tv.setText(translators); break; case ACTION_LICENSE: WebView wv = (WebView) rootView.findViewById(R.id.licence_page); wv.loadUrl("file:///android_asset/licence.html"); break; } return rootView; }
From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java
protected void applicenseDialog() { final Dialog aLDialog = new Dialog(IntroActivity.this); aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); aLDialog.setTitle("License Agreement"); aLDialog.setCancelable(false);/* w w w .j a v a2 s . c o m*/ aLDialog.setCanceledOnTouchOutside(false); aLDialog.setContentView(R.layout.app_license_dialog); WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic); Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree); Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree); lic.getSettings().setUseWideViewPort(true); lic.loadUrl("file:///android_asset/atomizeLicense.html"); disagree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { aLDialog.dismiss(); SharedPreferences.Editor e = getPrefs.edit(); e.putBoolean("agreedToLicense", false); e.apply(); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homeIntent); IntroActivity.this.finish(); MainActivity.getInstance().finish(); } }); agree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences.Editor e = getPrefs.edit(); e.putBoolean("agreedToLicense", true); e.apply(); aLDialog.dismiss(); } }); aLDialog.show(); }
From source file:com.appnexus.opensdk.ANNativeAdResponse.java
boolean handleClick(String clickUrl, Context context) { if (clickUrl == null || clickUrl.isEmpty()) { return false; }// w w w .j av a2 s.c o m // if install, open store if (clickUrl.contains("://play.google.com") || clickUrl.contains("market://")) { Clog.d(Clog.nativeLogTag, Clog.getString(R.string.opening_app_store)); return openNativeIntent(clickUrl, context); } // open browser if (openNativeBrowser) { // if set to use native browser, open intent if (openNativeIntent(clickUrl, context)) { if (listener != null) { listener.onAdWillLeaveApplication(); } return true; } return false; } else { // launch Browser Activity Class<?> activity_clz = AdActivity.getActivityClass(); try { WebView out = new WebView(new MutableContextWrapper(context)); WebviewUtil.setWebViewSettings(out); out.loadUrl(clickUrl); BrowserAdActivity.BROWSER_QUEUE.add(out); Intent intent = new Intent(context, activity_clz); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER); context.startActivity(intent); return true; } catch (ActivityNotFoundException e) { Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName())); BrowserAdActivity.BROWSER_QUEUE.remove(); } catch (Exception e) { // Catches PackageManager$NameNotFoundException for webview Clog.e(Clog.baseLogTag, "Exception initializing the redirect webview: " + e.getMessage()); return false; } return false; } }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
public static void showAboutDialog(final Context mContext) { LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = li.inflate(R.layout.about, null); String sVersionInfo = ""; try {/* w w w .j ava 2 s . c o m*/ PackageInfo pi = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0); sVersionInfo += pi.versionName; if (!pi.versionName.contains("" + pi.versionCode)) sVersionInfo += " (" + pi.versionCode + ")"; if (OpenExplorer.IS_DEBUG_BUILD) sVersionInfo += " *debug*"; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String sBuildTime = ""; try { sBuildTime = SimpleDateFormat.getInstance() .format(new Date(new ZipFile( mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), 0).sourceDir) .getEntry("classes.dex").getTime())); } catch (Exception e) { Logger.LogError("Couldn't get Build Time.", e); } WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); Display d = wm.getDefaultDisplay(); String sHardwareInfo = "Display:\n"; sHardwareInfo += "Size: " + d.getWidth() + "x" + d.getHeight() + "\n"; if (dm != null) sHardwareInfo += "Density: " + dm.density + "\n"; sHardwareInfo += "Rotation: " + d.getRotation() + "\n\n"; sHardwareInfo += getNetworkInfo(mContext); sHardwareInfo += getDeviceInfo(); ((TextView) view.findViewById(R.id.about_hardware)).setText(sHardwareInfo); final String sSubject = "Feedback for OpenExplorer " + sVersionInfo; OnClickListener email = new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); //intent.addCategory(Intent.CATEGORY_APP_EMAIL); intent.putExtra(android.content.Intent.EXTRA_TEXT, "\n" + getDeviceInfo()); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "brandroid64@gmail.com" }); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, sSubject); mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.s_chooser_email))); } }; OnClickListener viewsite = new OnClickListener() { public void onClick(View v) { mContext.startActivity( new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://brandroid.org/open/"))); } }; view.findViewById(R.id.about_email).setOnClickListener(email); view.findViewById(R.id.about_email_btn).setOnClickListener(email); view.findViewById(R.id.about_site).setOnClickListener(viewsite); view.findViewById(R.id.about_site_btn).setOnClickListener(viewsite); final View mRecentLabel = view.findViewById(R.id.about_recent_status_label); final WebView mRecent = (WebView) view.findViewById(R.id.about_recent); final OpenChromeClient occ = new OpenChromeClient(); occ.mStatus = (TextView) view.findViewById(R.id.about_recent_status); mRecent.setWebChromeClient(occ); mRecent.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { occ.mStatus.setVisibility(View.GONE); mRecent.setVisibility(View.GONE); mRecentLabel.setVisibility(View.GONE); } }); mRecent.setBackgroundColor(Color.TRANSPARENT); mRecent.loadUrl("http://brandroid.org/open/?show=recent"); ((TextView) view.findViewById(R.id.about_version)).setText(sVersionInfo); if (sBuildTime != "") ((TextView) view.findViewById(R.id.about_buildtime)).setText(sBuildTime); else ((TableRow) view.findViewById(R.id.row_buildtime)).setVisibility(View.GONE); fillShortcutsTable((TableLayout) view.findViewById(R.id.shortcuts_table)); final View tab1 = view.findViewById(R.id.tab1); final View tab2 = view.findViewById(R.id.tab2); final View tab3 = view.findViewById(R.id.tab3); ((Button) view.findViewById(R.id.btn_recent)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.VISIBLE); tab2.setVisibility(View.GONE); tab3.setVisibility(View.GONE); } }); ((Button) view.findViewById(R.id.btn_hardware)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.GONE); tab2.setVisibility(View.VISIBLE); tab3.setVisibility(View.GONE); } }); ((Button) view.findViewById(R.id.btn_shortcuts)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tab1.setVisibility(View.GONE); tab2.setVisibility(View.GONE); tab3.setVisibility(View.VISIBLE); } }); AlertDialog mDlgAbout = new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setView(view) .create(); mDlgAbout.getWindow().getAttributes().windowAnimations = R.style.SlideDialogAnimation; mDlgAbout.getWindow().getAttributes().alpha = 0.9f; mDlgAbout.show(); }
From source file:com.apotheosis.acceleration.monitor.MainMenuActivity.java
@Override public void onResume() { super.onResume(); initRecorderFragment();//from w w w . j av a 2 s . c o m final SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (!defaultPrefs.getBoolean("LICENSES_ACCEPTED", false)) { final AlertDialog.Builder acceptLicenses = new AlertDialog.Builder(this); View v = getLayoutInflater().inflate(R.layout.alertdialog_license_prompt, null); acceptLicenses.setView(v); WebView cpol = (WebView) v.findViewById(R.id.CPOL_view), apache = (WebView) v.findViewById(R.id.APACHE_2_0_view); cpol.loadUrl("file:///android_res/raw/cpol.html"); cpol.getSettings().setLoadWithOverviewMode(true); cpol.getSettings().setBuiltInZoomControls(true); cpol.getSettings().setUseWideViewPort(true); apache.loadUrl("file:///android_res/raw/apache.html"); apache.getSettings().setLoadWithOverviewMode(true); apache.getSettings().setBuiltInZoomControls(true); apache.getSettings().setUseWideViewPort(true); acceptLicenses.setPositiveButton("Accept", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { defaultPrefs.edit().putBoolean("LICENSES_ACCEPTED", true).apply(); dialog.dismiss(); PreferenceManager.setDefaultValues(MainMenuActivity.this, R.xml.data_viewer_phone_options, false); } }); acceptLicenses.setNegativeButton("Decline", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); acceptLicenses.setCancelable(false); acceptLicenses.show(); } }
From source file:org.apache.taverna.mobile.ui.DashboardActivity.java
/** * @param navigationView Design Support NavigationView OnClick Listener Event *///from ww w. j av a 2 s .co m private void setupDrawerContent(final NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.nav_workflows: fragment = new WorkflowFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_all_workflows); return true; case R.id.nav_my_workflows: fragment = new MyWorkflowFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_my_workflows); return true; case R.id.nav_favourite_workflow: fragment = new FavouriteWorkflowsFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_favourite_workflows); return true; case R.id.nav_announcement: fragment = new AnnouncementFragment(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, R.id.frame_container); menuItem.setChecked(true); mDrawerLayout.closeDrawers(); toolbar.setTitle(R.string.title_nav_announcement); return true; case R.id.nav_usage: dialog.setCanceledOnTouchOutside(true); dialog.setTitle(getString(R.string.title_nav_usage)); dialog.setContentView(R.layout.usage_layout); dialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.nav_about: TableLayout about = (TableLayout) getLayoutInflater().inflate(R.layout.about, navigationView, false); dialog.setCanceledOnTouchOutside(true); dialog.setTitle(getString(R.string.title_about)); dialog.setContentView(about); dialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.os_licences: WebView webView = (WebView) getLayoutInflater().inflate(R.layout.fragment_licence, navigationView, false); webView.getSettings().setUseWideViewPort(true); webView.loadUrl("file:///android_asset/licences.html"); AlertDialog alertDialog = new AlertDialog.Builder(DashboardActivity.this, R.style.Theme_Taverna_Dialog).setTitle(getString(R.string.title_nav_os_licences)) .setView(webView).setPositiveButton(android.R.string.ok, null).create(); alertDialog.show(); mDrawerLayout.closeDrawers(); return true; case R.id.nav_settings: startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right); mDrawerLayout.closeDrawers(); return true; case R.id.nav_logout: mDrawerLayout.closeDrawers(); dataManager.getPreferencesHelper().setLoggedInFlag(false); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); finish(); return true; } return true; } }); }
From source file:a.dev.mobile.thread.MainActivity.java
/** * ********/*from w w w .j a v a 2s. co m*/ */ public void clickOpen(View view) { WebView webView = new WebView(this); webView.loadUrl("file:///android_asset/licenses.html"); new AlertDialog.Builder(this).setTitle(R.string.dialog_licenses_notice_title).setView(webView) .setCancelable(true).show(); }
From source file:com.github.federvieh.selma.NavigationDrawerFragment.java
/** * *//*w w w .j av a 2 s . c o m*/ protected void openGPL() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View layoutView = inflater.inflate(R.layout.license_view, null); builder.setView(layoutView); WebView webView = (WebView) layoutView.findViewById(R.id.webViewLicense); webView.loadUrl("file:///android_res/raw/gpl_3_0_standalone.html"); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User closed the dialog } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.sahildave.snackbar.SnackBar.java
private View addLargeContainer(MessageType messageType, String inputUrl) { View v = activity.getLayoutInflater().inflate(R.layout.usb_large_container, null); WebView webView = (WebView) v.findViewById(R.id.snackWebview); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override//from w w w . j av a 2 s. c o m public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); webView.loadUrl(inputUrl); v.setTag(messageType); addToView(v); return v; }
From source file:com.chatwingsdk.managers.CommunicationModeManager.java
private void subscribeToConversationChannels(WebView mWebView) { if (mUserManager.getCurrentUser() == null) { return;/*from w w w.j a va2 s. c om*/ } String js = String.format("javascript:subscribe('/user/%s')", mUserManager.getCurrentUser().getId()); mWebView.loadUrl(js); }