List of usage examples for android.webkit WebView loadUrl
public void loadUrl(String url)
From source file:org.runnerup.view.MainLayout.java
public void whatsNew() { AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getSystemService(Service.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.whatsnew, null); WebView wv = (WebView) view.findViewById(R.id.web_view1); builder.setTitle(getString(R.string.Whats_new)); builder.setView(view);//from w w w. j av a 2 s . c om builder.setPositiveButton(getString(R.string.Rate_RunnerUp), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onRateClick.onClick(null); } }); builder.setNegativeButton(getString(R.string.Dismiss), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); wv.loadUrl("file:///android_asset/changes.html"); }
From source file:com.aniruddhc.acemusic.player.Utils.Common.java
@Override public void onCreate() { super.onCreate(); //Application context. mContext = getApplicationContext();/*from www. j av a2 s .co m*/ //SharedPreferences. mSharedPreferences = this.getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); //Init the database. mDBAccessHelper = new DBAccessHelper(mContext); //Playback kickstarter. mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext()); //Picasso. mPicasso = new Picasso.Builder(mContext).build(); //ImageLoader. mImageLoader = ImageLoader.getInstance(); mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13) .imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build(); mImageLoader.init(mImageLoaderConfiguration); //Init DisplayImageOptions. initDisplayImageOptions(); //Log the user into Google Play Music only if the account is currently set up and active. if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) { //Create a temp WebView to retrieve the user agent string. String userAgentString = ""; if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) { WebView webView = new WebView(getApplicationContext()); webView.setVisibility(View.GONE); webView.loadUrl("http://www.google.com"); userAgentString = webView.getSettings().getUserAgentString(); mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit(); mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit(); webView = null; } setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext())); GMusicClientCalls.setWebClientUserAgent(userAgentString); String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", ""); //Authenticate with Google. AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName); task.execute(); } }
From source file:com.jelly.music.player.Utils.Common.java
@Override public void onCreate() { super.onCreate(); //Application context. mContext = getApplicationContext();// w w w. j a va 2 s .c o m //SharedPreferences. mSharedPreferences = this.getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE); //Init the database. mDBAccessHelper = new DBAccessHelper(mContext); //Playback kickstarter. mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext()); //Picasso. mPicasso = new Picasso.Builder(mContext).build(); //ImageLoader. mImageLoader = ImageLoader.getInstance(); mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13) .imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build(); mImageLoader.init(mImageLoaderConfiguration); //Init DisplayImageOptions. initDisplayImageOptions(); //Log the user into Google Play Music only if the account is currently set up and active. if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) { //Create a temp WebView to retrieve the user agent string. String userAgentString = ""; if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) { WebView webView = new WebView(getApplicationContext()); webView.setVisibility(View.GONE); webView.loadUrl("http://www.google.com"); userAgentString = webView.getSettings().getUserAgentString(); mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit(); mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit(); webView = null; } setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext())); GMusicClientCalls.setWebClientUserAgent(userAgentString); String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", ""); //Authenticate with Google. AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName); task.execute(); } }
From source file:com.nestlabs.sdk.NestAuthActivity.java
@Override @SuppressLint("SetJavaScriptEnabled") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nest_auth_webview_layout); WebView clientWebView = (WebView) findViewById(R.id.auth_webview); mProgressBar = (ProgressBar) findViewById(R.id.webview_progress); mNestConfig = getIntent().getParcelableExtra(KEY_CLIENT_METADATA); // If any args are empty, they are invalid and we should finish. if (mNestConfig == null || Utils.isAnyEmpty(mNestConfig.getRedirectURL(), mNestConfig.getClientID(), mNestConfig.getStateValue())) { finishWithResult(RESULT_CANCELED, null); return;//from w w w.j a va2 s . c o m } mHttpClient = new OkHttpClient(); clientWebView.setWebChromeClient(new ProgressChromeClient()); clientWebView.setWebViewClient(new RedirectClient()); String url = String.format(NestAPI.CLIENT_CODE_URL, mNestConfig.getClientID(), mNestConfig.getStateValue()); WebSettings webSettings = clientWebView.getSettings(); webSettings.setJavaScriptEnabled(true); clientWebView.loadUrl(url); }
From source file:com.Duo.music.player.Utils.Common.java
@Override public void onCreate() { super.onCreate(); //Application context. mContext = getApplicationContext();//from www .j a v a 2 s.co m //SharedPreferences. mSharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Init the database. mDBAccessHelper = new DBAccessHelper(mContext); //Playback kickstarter. mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext()); //Picasso. mPicasso = new Picasso.Builder(mContext).build(); //ImageLoader. mImageLoader = ImageLoader.getInstance(); mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13) .imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build(); mImageLoader.init(mImageLoaderConfiguration); //Init DisplayImageOptions. initDisplayImageOptions(); //Log the user into Google Play Music only if the account is currently set up and active. if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) { //Create a temp WebView to retrieve the user agent string. String userAgentString = ""; if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) { WebView webView = new WebView(getApplicationContext()); webView.setVisibility(View.GONE); webView.loadUrl("http://www.google.com"); userAgentString = webView.getSettings().getUserAgentString(); mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit(); mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit(); webView = null; } setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext())); GMusicClientCalls.setWebClientUserAgent(userAgentString); String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", ""); //Authenticate with Google. AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName); task.execute(); } }
From source file:com.rsltc.profiledata.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button loginButton = (Button) findViewById(R.id.button); loginButton.setOnClickListener(new View.OnClickListener() { @Override/*from w ww. j a va 2s. c om*/ public void onClick(View v) { try { AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity); alert.setTitle("Title here"); StringBuilder query = new StringBuilder(); query.append("redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8")); query.append("&client_id=" + URLEncoder.encode(clientId, "utf-8")); query.append("&scope=" + URLEncoder.encode(scopes, "utf-8")); query.append("&response_type=code"); URI uri = new URI("https://login.live.com/oauth20_authorize.srf?" + query.toString()); URL url = uri.toURL(); final WebView wv = new WebView(thisActivity); WebSettings webSettings = wv.getSettings(); webSettings.setJavaScriptEnabled(true); wv.loadUrl(url.toString()); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String location) { Log.e(TAG, location); // TODO: extract to method try { URL url = new URL(location); if (url.getPath().equalsIgnoreCase("/oauth20_desktop.srf")) { System.out.println("Dit werkt al!"); System.out.println(url.getQuery()); Map<String, List<String>> result = splitQuery(url); if (result.containsKey("code")) { System.out.println("bevat code"); if (result.containsKey("error")) { System.out.println(String.format("{0}\r\n{1}", result.get("error"), result.get("errorDesc"))); } System.out.println(result.get("code").get(0)); String tokenError = GetToken(result.get("code").get(0), false); if (tokenError == null || "".equals(tokenError)) { System.out.println("Successful sign-in!"); Log.e(TAG, "Successful sign-in!"); } else { Log.e(TAG, "tokenError: " + tokenError); } } else { System.out.println("Successful sign-out!"); } } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } view.loadUrl(location); return true; } }); LinearLayout linearLayout = new LinearLayout(thisActivity); linearLayout.setMinimumHeight(500); ArrayList<View> views = new ArrayList<View>(); views.add(wv); linearLayout.addView(wv); EditText text = new EditText(thisActivity); text.setVisibility(View.GONE); linearLayout.addView(text); alert.setView(linearLayout); alert.setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert.show(); } catch (Exception e) { Log.e(TAG, "dd"); } } }); Button showProfile = (Button) findViewById(R.id.button2); showProfile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showProfile(); } }); Button showSummmary = (Button) findViewById(R.id.button3); showSummmary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showSummaries(); } }); if (savedInstanceState != null) { authInProgress = savedInstanceState.getBoolean(AUTH_PENDING); } buildFitnessClient(); }
From source file:com.elpstudio.player.externals.Common.java
@Override public void onCreate() { super.onCreate(); //Application context. mContext = getApplicationContext();//from w w w.j ava 2 s . c o m sInstance = this; light = Typeface.createFromAsset(getApplicationContext().getAssets(), "segoeuil.ttf"); reg = Typeface.createFromAsset(getApplicationContext().getAssets(), "segoeui.ttf"); //SharedPreferences. mSharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Init the database. mDBAccessHelper = new DBAccessHelper(mContext); //Playback kickstarter. //mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext()); //Picasso. // mPicasso = new Picasso.Builder(mContext).build(); //ImageLoader. mImageLoader = ImageLoader.getInstance(); mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13) .imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build(); mImageLoader.init(mImageLoaderConfiguration); //Init DisplayImageOptions. initDisplayImageOptions(); //Log the user into Google Play Music only if the account is currently set up and active. if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) { //Create a temp WebView to retrieve the user agent string. String userAgentString = ""; if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) { WebView webView = new WebView(getApplicationContext()); webView.setVisibility(View.GONE); webView.loadUrl("http://www.google.com"); userAgentString = webView.getSettings().getUserAgentString(); mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit(); mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit(); webView = null; } /*setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext())); GMusicClientCalls.setWebClientUserAgent(userAgentString); String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", ""); //Authenticate with Google. AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName); task.execute(); */ } }
From source file:com.activiti.android.app.fragments.HelpDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.app_webview, container, false); getToolbar().setVisibility(View.GONE); webView = (WebView) v.findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); emptyView = v.findViewById(R.id.empty); emptyTextView = (TextView) v.findViewById(R.id.empty_text); emptyTextView.setText(Html.fromHtml(getString(R.string.error_offline))); final Activity activity = getActivity(); defaultUrl = activity.getString(R.string.help_user_guide_default_url); webView.setWebViewClient(new WebViewClient() { boolean hasError = false; @Override//from w w w .j a va 2s. co m public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); hasError = false; getActivity().setProgressBarIndeterminateVisibility(true); refreshIcon.setVisible(false); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); // We redirect to default EN documentation if locale docs are // not available. if ((errorCode == ERROR_FILE_NOT_FOUND || errorCode == ERROR_HOST_LOOKUP) && !isDefault && failingUrl.equals(rootUrl)) { hasError = true; view.loadUrl(defaultUrl); view.setVisibility(View.GONE); } else if (!ConnectivityUtils.hasInternetAvailable(getActivity())) { view.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); hasError = true; } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (hasError) { view.setVisibility(View.GONE); } else { view.setVisibility(View.VISIBLE); } if (getActivity() != null) { getActivity().setProgressBarIndeterminateVisibility(false); refreshIcon.setVisible(true); } } public void onFormResubmission(WebView view, Message dontResend, Message resend) { resend.sendToTarget(); } }); webView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (webView.canGoBack()) { webView.goBack(); return true; } break; } } return false; } }); rootUrl = getUrl(activity); webView.loadUrl(rootUrl); return v; }
From source file:jp.mixi.android.sdk.MixiDialog.java
private WebView setUpWebView(WebView webView) { Log.v(TAG, "setwebview"); webView.getSettings().setUserAgentString(Constants.USER_AGENT); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); webView.setWebViewClient(new MixiWebviewClient()); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(new JsHandler(), "mixi"); String token = mParams.get("oauth_token"); int sdkInt = Integer.valueOf(Build.VERSION.SDK); // android2.1 if (sdkInt < Constants.SUPPORTED_SDK_VERSION) { Uri uri = Uri.parse(mUrl);/*from www . j a va 2 s .c o m*/ if (token != null) { Builder builder = uri.buildUpon(); builder.appendQueryParameter("oauth_token", token); uri = builder.build(); } webView.loadUrl(uri.toString()); } else { HashMap<String, String> extraHeaders = new HashMap<String, String>(); if (token != null) { extraHeaders.put("Authorization", "OAuth " + token); } webView.loadUrl(mUrl, extraHeaders); } return webView; }
From source file:org.apache.cordova.InAppBrowser.java
/** * Closes the dialog// w w w. java 2 s .co m */ public void closeDialog() { final WebView childView = this.inAppWebView; // The JS protects against multiple calls, so this should happen only when // closeDialog() is called by other native code. if (childView == null) { return; } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { childView.loadUrl("about:blank"); if (dialog != null) { dialog.dismiss(); } } }); try { JSONObject obj = new JSONObject(); obj.put("type", EXIT_EVENT); sendUpdate(obj, false); } catch (JSONException ex) { Log.d(LOG_TAG, "Should never happen"); } }