Java Code Examples for android.webkit.WebView

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: BlobViewFragment.java

  19 
vote

public void displayBlob(){
  WebView webView=getWebView();
  WebSettings settings=webView.getSettings();
  settings.setUseWideViewPort(true);
  settings.setJavaScriptEnabled(true);
  settings.setBuiltInZoomControls(true);
  if (Build.VERSION.SDK_INT >= HONEYCOMB) {
    settings.setDisplayZoomControls(false);
  }
  webView.loadDataWithBaseURL("file:///android_asset",blobHTML,"text/html","UTF-8",null);
}
 

Example 2

From project andlytics, under directory /src/com/github/andlyticsproject/util/.

Source file: ChangelogBuilder.java

  18 
vote

/** 
 * Show the dialog only if not already shown for this version of the application.
 * @param context the context
 * @param listener the listener to be set for the clickevent of the 'OK' button
 * @return the 'Changelog' dialog
 */
public static AlertDialog create(final Context context,final Dialog.OnClickListener listener){
  View view=LayoutInflater.from(context).inflate(R.layout.changelog,null);
  WebView webView=(WebView)view.findViewById(R.id.changelogcontent);
  try {
    webView.loadData(DataLoader.loadData(context,"changelog"),"text/html","UTF-8");
  }
 catch (  IOException ioe) {
    Log.e(TAG,"Error reading changelog file!",ioe);
  }
  return new AlertDialog.Builder(context).setTitle(context.getString(R.string.changelog_title) + "\n" + context.getString(R.string.app_name)+ " v"+ Utils.getActualVersionName(context)).setIcon(R.drawable.icon).setView(view).setPositiveButton(android.R.string.ok,listener).create();
}
 

Example 3

From project Android-automation, under directory /Tmts_Java/src/com/taobao/tmts/framework/.

Source file: Tmts.java

  18 
vote

/** 
 * Return a  {@link TmtsWebView} by the given name.
 * @param name String name of view id, the string after @+id/ defined in layout files.
 * @return {@link TmtsWebView} with the given name.
 * @throws Exception Exception
 */
TmtsWebView getTmtsWebView(String name) throws Exception {
  Log.i(LOG_TAG,"getTmtsWebView: " + name);
  WebView webView=(WebView)getWebViewById(name);
  while (!(webView.getProgress() == 100)) {
    Thread.sleep(1000);
    Log.i(LOG_TAG,"sleep: " + webView.getProgress());
  }
  printLog(webView,name,"getTmtsWebView");
  Log.i(LOG_TAG,"getTmtsWebView: " + webView + " success");
  Log.i(LOG_TAG,"getTmtsWebViewurl: " + webView.getUrl() + " success");
  Thread.sleep(2000);
  TmtsWebView tmtsWebView=new TmtsWebView(inst,webView);
  return tmtsWebView;
}
 

Example 4

From project android-context, under directory /defunct/shared/.

Source file: HelpActivity.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.help);
  WebView wv=(WebView)findViewById(R.id.helpWebView);
  wv.loadUrl("file:///android_asset/help.html");
}
 

Example 5

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: WebViewDialog.java

  18 
vote

public void loadURL(String url){
  WebView wv=(WebView)findViewById(R.id.WebView);
  if (wv != null) {
    wv.loadUrl(url);
    setTitle(wv.getTitle());
  }
 else {
    mURL=url;
  }
}
 

Example 6

From project android-pulltorefresh, under directory /library/src/com/handmark/pulltorefresh/library/.

Source file: PullToRefreshWebView.java

  18 
vote

@Override protected WebView createRefreshableView(Context context,AttributeSet attrs){
  WebView webView;
  if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
    webView=new InternalWebViewSDK9(context,attrs);
  }
 else {
    webView=new WebView(context,attrs);
  }
  webView.setId(R.id.webview);
  return webView;
}
 

Example 7

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: ChangeLog.java

  18 
vote

private AlertDialog getDialog(boolean full){
  WebView wv=new WebView(this.context);
  wv.setBackgroundColor(0);
  wv.loadData(this.getLog(full),"text/html","UTF-8");
  AlertDialog.Builder builder=new AlertDialog.Builder(this.context);
  builder.setTitle(context.getResources().getString(full ? R.string.changelog_full_title : R.string.changelog_title)).setView(wv).setCancelable(true).setPositiveButton(context.getResources().getString(R.string.ok),new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
);
  return builder.create();
}
 

Example 8

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: About.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(getAboutTitle());
  setContentView(R.layout.about);
  WebView webview=(WebView)findViewById(R.id.about);
  webview.loadDataWithBaseURL("",getResources().getString(R.string.about_content),"text/html","utf-8",null);
}
 

Example 9

From project apps-for-android, under directory /Translate/src/com/beust/android/translate/.

Source file: AboutDialog.java

  18 
vote

protected AboutDialog(Context context){
  super(context);
  setContentView(R.layout.about_dialog);
  setTitle(R.string.about_title);
  setCancelable(true);
  WebView webView=(WebView)findViewById(R.id.webview);
  webView.loadData("Written by C&eacute;dric Beust (<a href=\"mailto:[email protected]\">[email protected])</a>","text/html","utf-8");
}
 

Example 10

From project BART, under directory /src/pro/dbro/bart/.

Source file: MapActivity.java

  18 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  WebView webview=new WebView(this);
  webview.getSettings().setBuiltInZoomControls(true);
  webview.loadUrl("file:///android_asset/bart_map.html");
  setContentView(webview);
}
 

Example 11

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/ui/.

Source file: BaseActivity.java

  18 
vote

private Dialog createHtmlDialog(String title,int contentResourceId,String pageName){
  AnalyticsUtils.trackPageView(pageName);
  WebView webView=new WebView(this);
  webView.loadDataWithBaseURL(null,Util.readTextFromResource(this,contentResourceId),"text/html","utf-8",null);
  return new AlertDialog.Builder(this).setTitle(title).setView(webView).setPositiveButton(android.R.string.ok,null).setNeutralButton(R.string.rate,new OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + getPackageName())));
    }
  }
).create();
}
 

Example 12

From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/main/.

Source file: Beintoo.java

  18 
vote

public static void getUA(){
  try {
    WebView wv=new WebView(Beintoo.currentContext);
    userAgent=wv.getSettings().getUserAgentString();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 13

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/activity/.

Source file: HelpActivity.java

  18 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.help);
  ViewUtils.setActionBarBackground(this);
  String helpText=FsUtils.getAssetString(getApplicationContext(),"help.html");
  WebView vWeb=(WebView)findViewById(R.id.helpView);
  vWeb.loadDataWithBaseURL("file:///url_initial_load",helpText,"text/html","UTF-8","about:config");
}
 

Example 14

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: RequestCoinsActivity.java

  18 
vote

@Override protected Dialog onCreateDialog(final int id){
  final WebView webView=new WebView(this);
  webView.loadUrl("file:///android_asset/help_request_coins" + languagePrefix() + ".html");
  final Dialog dialog=new Dialog(this);
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  dialog.setContentView(webView);
  dialog.setCanceledOnTouchOutside(true);
  return dialog;
}
 

Example 15

From project Cafe, under directory /webapp/src/org/openqa/selenium/android/.

Source file: ChromeClient.java

  18 
vote

@Override public boolean onCreateWindow(WebView view,boolean dialog,boolean userGesture,Message resultMsg){
  WebView newView=WebDriverWebView.create(driver);
  WebView.WebViewTransport transport=(WebView.WebViewTransport)resultMsg.obj;
  transport.setWebView(newView);
  resultMsg.sendToTarget();
  driver.getViewManager().addView(newView);
  return true;
}
 

Example 16

From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/activities/.

Source file: Feedback.java

  18 
vote

/** 
 * onCreate
 * @param saved_instance_state
 */
@Override public void onCreate(Bundle saved_instance_state){
  super.onCreate(saved_instance_state);
  GeneratedResources.generate(this);
  setContentView(GeneratedResources.getLayout("feedback"));
  WebView view=(WebView)findViewById(GeneratedResources.getId("feedback"));
  view.getSettings().setJavaScriptEnabled(true);
  view.loadUrl("https://getsatisfaction.com/checkin4me/");
}
 

Example 17

From project cw-advandroid, under directory /Honeycomb/FeedFragments/src/com/commonsware/android/feedfrags/.

Source file: ContentFragment.java

  18 
vote

@Override public void onActivityCreated(Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  WebView browser=getBrowser();
  browser.setWebViewClient(new RedirectFixer());
  browser.getSettings().setJavaScriptEnabled(true);
  if (savedInstanceState != null) {
    browser.restoreState(savedInstanceState);
  }
 else   if (urlToLoad != null) {
    loadUrl(urlToLoad);
  }
}
 

Example 18

From project daisy-android-common, under directory /src/com/daisyworks/android/.

Source file: HelpActivity.java

  18 
vote

@Override protected void onCreate(final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.help);
  WebView webView=(WebView)findViewById(R.id.help_webview);
  webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
  webView.loadUrl("file:///android_asset/help.html");
}
 

Example 19

From project DigitbooksExamples, under directory /DigitbooksExamples/src/fr/digitbooks/android/examples/chapitre09/.

Source file: WebChromeClientActivity.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.web_chrome_client);
  mTitle=(TextView)findViewById(R.id.title);
  mProgress=(TextView)findViewById(R.id.progress);
  final WebView webView=(WebView)findViewById(R.id.webContent);
  webView.setWebChromeClient(mChromeClient);
  webView.clearCache(true);
  WebSettings webSettings=webView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  setupChrome();
  webView.loadUrl(getString(R.string.android_website));
}
 

Example 20

From project dmix, under directory /MPDroid/src/com/namelessdev/mpdroid/.

Source file: WebViewActivity.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  WebView webview=new WebView(this);
  this.setContentView(webview);
  final String url=getIntent().getStringExtra("url");
  if (url != null) {
    webview.loadUrl(url);
  }
 else {
    webview.loadUrl("http://nlss.fr/mpdroid/new.html");
  }
}
 

Example 21

From project Ebento, under directory /src/mobisocial/bento/ebento/ui/.

Source file: EventListActivity.java

  18 
vote

private void goInfo(){
  LayoutInflater factory=LayoutInflater.from(this);
  final View inputView=factory.inflate(R.layout.dialog_info,null);
  final WebView webView=(WebView)inputView.findViewById(R.id.webview);
  webView.loadUrl("file:///android_asset/license.html");
  AlertDialog.Builder libDialog=new AlertDialog.Builder(this).setTitle(R.string.info_dialog_title).setIcon(android.R.drawable.ic_dialog_info).setView(inputView).setCancelable(false).setPositiveButton(R.string.info_dialog_ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
);
  libDialog.create().show();
}
 

Example 22

From project Airports, under directory /src/com/nadmm/airports/.

Source file: AboutActivity.java

  17 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.about_view);
  WebView webView=(WebView)findViewById(R.id.about_content);
  webView.loadUrl("file:///android_asset/about.html");
  Button btnDonate=(Button)findViewById(R.id.btn_donate);
  btnDonate.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(AboutActivity.this,DonateActivity.class);
      startActivity(intent);
    }
  }
);
  Button btnOk=(Button)findViewById(R.id.btn_close);
  btnOk.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      finish();
    }
  }
);
  Button btnRate=(Button)findViewById(R.id.btn_rate);
  btnRate.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent urlIntent=new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + getPackageName()));
      startActivity(urlIntent);
    }
  }
);
}
 

Example 23

From project android-joedayz, under directory /Proyectos/AndroidFoursquare/src/com/mycompany/fsq/.

Source file: FoursquareDialog.java

  17 
vote

private void setUpWebView(){
  mWebView=new WebView(getContext());
  mWebView.setVerticalScrollBarEnabled(false);
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setWebViewClient(new TwitterWebViewClient());
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl(mUrl);
  mWebView.setLayoutParams(FILL);
  mContent.addView(mWebView);
}
 

Example 24

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/facebook/extpack/com/facebook/android/.

Source file: FbDialog.java

  17 
vote

private void setUpWebView(int margin){
  LinearLayout webViewContainer=new LinearLayout(getContext());
  mWebView=new WebView(getContext());
  mWebView.setVerticalScrollBarEnabled(false);
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setWebViewClient(new FbDialog.FbWebViewClient());
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl(mUrl);
  mWebView.setLayoutParams(FILL);
  mWebView.setVisibility(View.INVISIBLE);
  webViewContainer.setPadding(margin,margin,margin,margin);
  webViewContainer.addView(mWebView);
  mContent.addView(webViewContainer);
}
 

Example 25

From project android-tether, under directory /facebook/src/com/facebook/android/.

Source file: FbDialog.java

  17 
vote

private void setUpWebView(int margin){
  LinearLayout webViewContainer=new LinearLayout(getContext());
  mWebView=new WebView(getContext());
  mWebView.setVerticalScrollBarEnabled(false);
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setWebViewClient(new FbDialog.FbWebViewClient());
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl(mUrl);
  mWebView.setLayoutParams(FILL);
  mWebView.setVisibility(View.INVISIBLE);
  webViewContainer.setPadding(margin,margin,margin,margin);
  webViewContainer.addView(mWebView);
  mContent.addView(webViewContainer);
}
 

Example 26

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: BookDetailsActivity.java

  17 
vote

private void setupViews(){
  final FastBitmapDrawable defaultCover=new FastBitmapDrawable(BitmapFactory.decodeResource(getResources(),R.drawable.unknown_cover));
  final ImageView cover=(ImageView)findViewById(R.id.image_cover);
  cover.setImageDrawable(ImageUtilities.getCachedCover(mBook.getInternalId(),defaultCover));
  setTextOrHide(R.id.label_title,mBook.getTitle());
  setTextOrHide(R.id.label_author,TextUtilities.join(mBook.getAuthors(),", "));
  final int pages=mBook.getPagesCount();
  if (pages > 0) {
    ((TextView)findViewById(R.id.label_pages)).setText(getString(R.string.label_pages,pages));
  }
 else {
    findViewById(R.id.label_pages).setVisibility(View.GONE);
  }
  final Date publicationDate=mBook.getPublicationDate();
  if (publicationDate != null) {
    final String date=new SimpleDateFormat("MMMM yyyy").format(publicationDate);
    ((TextView)findViewById(R.id.label_date)).setText(date);
  }
 else {
    findViewById(R.id.label_date).setVisibility(View.GONE);
  }
  setTextOrHide(R.id.label_publisher,mBook.getPublisher());
  final WebView details=(WebView)findViewById(R.id.html_reviews);
  details.setBackgroundColor(0);
  details.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
  final WebSettings webSettings=details.getSettings();
  webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
  webSettings.setSavePassword(false);
  webSettings.setSaveFormData(false);
  webSettings.setJavaScriptEnabled(false);
  webSettings.setSupportZoom(false);
  webSettings.setBlockNetworkImage(true);
  details.loadData(mBook.getDescriptions().get(0).toString(),"text/html","utf-8");
}
 

Example 27

From project androidquery, under directory /auth/com/androidquery/.

Source file: WebDialog.java

  17 
vote

private void setupWebView(RelativeLayout layout){
  wv=new WebView(getContext());
  wv.setVerticalScrollBarEnabled(false);
  wv.setHorizontalScrollBarEnabled(false);
  if (client == null)   client=new WebViewClient();
  wv.setWebViewClient(new DialogWebViewClient());
  WebSettings ws=wv.getSettings();
  ws.setJavaScriptEnabled(true);
  RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT);
  layout.addView(wv,lp);
}
 

Example 28

From project android_7, under directory /src/org/immopoly/android/app/.

Source file: OauthLoginActivity.java

  17 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.oauth_login_activity);
  Intent intent=getIntent();
  if (intent != null) {
    String url=intent.getExtras().getString("oauth_url");
    WebView webView=(WebView)findViewById(R.id.webview);
    webView.setWebViewClient(new WebViewClient(){
      @Override public void onPageStarted(      WebView view,      String url,      Bitmap favicon){
        super.onPageStarted(view,url,favicon);
        if (url.matches(".+?state=authorized")) {
          SharedPreferences shared=getSharedPreferences("oauth",0);
          SharedPreferences.Editor editor=shared.edit();
          Uri uri=Uri.parse(url);
          String access_token=uri.getQueryParameter("oauth_token");
          editor.putString("oauth_token",access_token);
          editor.commit();
          OAuthData.getInstance(OauthLoginActivity.this).accessToken=access_token;
          Intent i=new Intent(OauthLoginActivity.this,ImmopolyActivity.class);
          startActivity(i);
          finish();
        }
      }
    }
);
    webView.loadUrl(url);
  }
}
 

Example 29

From project Binaural-Beats, under directory /src/com/ihunda/android/binauralbeat/.

Source file: Comments.java

  17 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setTheme(android.R.style.Theme_Dialog);
  setContentView(R.layout.comments);
  setTitle(R.string.comments_title);
  WebView w=(WebView)findViewById(R.id.commentView);
  w.setWebViewClient(new WebViewClient(){
  }
);
  WebSettings ws=w.getSettings();
  ws.setJavaScriptEnabled(true);
  ws.setBlockNetworkLoads(false);
  ws.setLoadsImagesAutomatically(true);
  String page=readRawTextFile(R.raw.comment);
  w.loadData(page,"application/xhtml+xml",null);
  Button button=(Button)findViewById(R.id.CommentBack);
  button.setOnClickListener(new OnClickListener(){
    public void onClick(    View v){
      Intent intent=getIntent();
      setResult(RESULT_OK,intent);
      finish();
    }
  }
);
}
 

Example 30

From project Birthdays, under directory /src/com/rexmenpara/birthdays/.

Source file: UpgradeService.java

  17 
vote

/** 
 * Return a change log string. Releases occur often enough that we don't expect change sets to be localized.
 * @param from
 * @param to
 * @return
 */
public void showChangeLog(Context context,int from){
  if (!(context instanceof Activity) || from == 0)   return;
  StringBuilder changeLog=new StringBuilder();
  if (from <= V1_5_R6)   newVersionString(changeLog,"1.5.R6 (September 20, 2010)",new String[]{"Fixed 'Invalid Birthday' bug.","Fixed crashs on Droid X.","Fixed the bug where birthday events were a day early","Better calendar cleanup"});
  if (from >= V1_5_R6 && from < V1_5)   newVersionString(changeLog,"1.5 (September 7, 2010)",new String[]{"Fixed the bug where birthday events were a day early","A few minor bugfixes and enhancements"});
  if (from >= V1_5 && from < V1_1)   newVersionString(changeLog,"1.1.beta",new String[]{"Fixed calendar sync issue on non-HTC devices"});
  if (from >= V1_1 && from < V1_0)   newVersionString(changeLog,"1.0.beta",new String[]{"Initial release"});
  if (changeLog.length() == 0)   return;
  changeLog.append("Enjoy!</body></html>");
  String changeLogHtml="<html><body style='color: white'>" + changeLog;
  WebView webView=new WebView(context);
  webView.loadData(changeLogHtml,"text/html","utf-8");
  webView.setBackgroundColor(0);
  new AlertDialog.Builder(context).setTitle("Latest Changes").setView(webView).setIcon(android.R.drawable.ic_dialog_info).setPositiveButton(android.R.string.ok,null).show();
}
 

Example 31

From project cw-android, under directory /Activities/IntentTab/src/com/commonsware/android/intenttab/.

Source file: CWBrowser.java

  17 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  browser=new WebView(this);
  setContentView(browser);
  browser.loadUrl(getIntent().getStringExtra(URL));
}
 

Example 32

From project cw-omnibus, under directory /EmPubLite/T10-ViewPager/src/com/commonsware/empublite/.

Source file: WebViewFragment.java

  17 
vote

/** 
 * Called to instantiate the view. Creates and returns the WebView.
 */
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (mWebView != null) {
    mWebView.destroy();
  }
  mWebView=new WebView(getActivity());
  mIsWebViewAvailable=true;
  return mWebView;
}
 

Example 33

From project droid-comic-viewer, under directory /src/net/robotmedia/acv/ui/widget/.

Source file: ComicFrame.java

  17 
vote

public void showContent(ACVComic acv,int screenIndex,int frameIndex,boolean forward,LayoutMeasures imageMeasures){
  this.removeContent();
  final List<ACVContent> contents=acv.getContents(screenIndex,frameIndex);
  final String baseURL=acv.getContentBaseURL();
  final Context context=getContext();
  for (  final ACVContent content : contents) {
    final Rect rect=content.createRect(imageMeasures.width,imageMeasures.height);
    final WebView w=new WebView(context);
    final int x=rect.left - imageMeasures.scrollX + imageMeasures.left;
    final int y=rect.top - imageMeasures.scrollY + imageMeasures.top;
    w.setLayoutParams(new AbsoluteLayout.LayoutParams(rect.width(),rect.height(),x,y));
    w.setVerticalScrollBarEnabled(false);
    w.setHorizontalScrollBarEnabled(false);
    w.setBackgroundColor(Color.TRANSPARENT);
    w.setClickable(false);
    w.setLongClickable(false);
    final String html=acv.getContentFromSource(content);
    w.loadDataWithBaseURL(baseURL,html,"text/html","UTF-8",null);
    mContentContainer.addView(w);
    mContentViews.add(w);
    w.setWebViewClient(new WebViewClient(){
      @Override public void onPageFinished(      WebView view,      String url){
        final long transitionDuration=content.getTransitionDuration();
        if (transitionDuration > 0) {
          final Animation animation=AnimationUtils.loadAnimation(context,android.R.anim.fade_in);
          animation.setDuration(transitionDuration);
          view.startAnimation(animation);
        }
      }
      @Override public boolean shouldOverrideUrlLoading(      WebView view,      String url){
        IntentUtils.view(context,url);
        return true;
      }
    }
);
  }
}
 

Example 34

From project dungbeetle, under directory /src/com/facebook/android/.

Source file: FbDialog.java

  17 
vote

private void setUpWebView(){
  mWebView=new WebView(getContext());
  mWebView.setVerticalScrollBarEnabled(false);
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setWebViewClient(new FbDialog.FbWebViewClient());
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.loadUrl(mUrl);
  mWebView.setLayoutParams(FILL);
  mContent.addView(mWebView);
}
 

Example 35

From project E12Planner, under directory /src/com/neoware/europlanner/.

Source file: WebViewActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.webview);
  BitmapDrawable bg=(BitmapDrawable)getResources().getDrawable(R.drawable.toolbar_bg);
  bg.setTileModeXY(TileMode.REPEAT,TileMode.REPEAT);
  ActionBar bar=getSupportActionBar();
  bar.setBackgroundDrawable(bg);
  bar.setTitle(R.string.news_title);
  bar.setHomeButtonEnabled(true);
  bar.setDisplayHomeAsUpEnabled(true);
  bar.setDisplayUseLogoEnabled(true);
  WebView wv=(WebView)findViewById(R.id.webView);
  wv.getSettings().setUserAgentString("Android");
  wv.setWebViewClient(new LocalRedirectClient());
  wv.getSettings().setJavaScriptEnabled(true);
  wv.getSettings().setLoadWithOverviewMode(true);
  wv.getSettings().setUseWideViewPort(true);
  wv.getSettings().setSupportZoom(true);
  wv.getSettings().setBuiltInZoomControls(true);
  Bundle extras=getIntent().getExtras();
  if (extras != null) {
    wv.loadUrl(extras.getString(URL_EXTRA));
  }
}
 

Example 36

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: SettingsSafetyLegalActivity.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  String userSafetylegalUrl=SystemProperties.get(PROPERTY_LSAFETYLEGAL_URL);
  final Configuration configuration=getResources().getConfiguration();
  final String language=configuration.locale.getLanguage();
  final String country=configuration.locale.getCountry();
  String loc=String.format("locale=%s-%s",language,country);
  userSafetylegalUrl=String.format("%s&%s",userSafetylegalUrl,loc);
  mWebView=new WebView(this);
  mWebView.getSettings().setJavaScriptEnabled(true);
  if (savedInstanceState == null) {
    mWebView.loadUrl(userSafetylegalUrl);
  }
 else {
    mWebView.restoreState(savedInstanceState);
  }
  mWebView.setWebViewClient(new WebViewClient(){
    @Override public void onPageFinished(    WebView view,    String url){
      mAlert.setTitle(getString(R.string.settings_safetylegal_activity_title));
    }
    @Override public void onReceivedError(    WebView view,    int errorCode,    String description,    String failingUrl){
      showErrorAndFinish(failingUrl);
    }
  }
);
  final AlertController.AlertParams p=mAlertParams;
  p.mTitle=getString(R.string.settings_safetylegal_activity_loading);
  p.mView=mWebView;
  p.mForceInverseBackground=true;
  setupAlert();
}
 

Example 37

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: WebViewActivity.java

  16 
vote

private void PrepareLayout(File fOut){
  if (view == null)   view=new WebView(this);
  WebSettings settings=view.getSettings();
  settings.setAllowFileAccess(true);
  settings.setBuiltInZoomControls(true);
  settings.setCacheMode(MODE_WORLD_WRITEABLE);
  settings.setJavaScriptEnabled(true);
  settings.setSupportMultipleWindows(false);
  settings.setJavaScriptEnabled(true);
  settings.setSaveFormData(false);
  String strVersionCode=new Integer(versionCode).toString();
  String strURL=strURLRoot + "/chmi/" + strVersionCode+ "/"+ chmiConfigBundle._strWebViewFile+ "?lang="+ chmiConfigBundle._locale+ "&ver="+ strVersionCode;
  try {
    chmiConfigBundle.saveSharedPreferences();
  }
 catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
  view.setWebChromeClient(new WebChromeClient(){
    public void onProgressChanged(    WebView view,    int progress){
      self.setProgress(progress * 100);
    }
  }
);
  view.setWebViewClient(new CHMIWebViewClient());
  view.loadUrl("file://" + fOut.getAbsolutePath());
  setContentView(view);
}
 

Example 38

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: SettingsLicenseActivity.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  String fileName=SystemProperties.get(PROPERTY_LICENSE_PATH,DEFAULT_LICENSE_PATH);
  if (TextUtils.isEmpty(fileName)) {
    Log.e(TAG,"The system property for the license file is empty.");
    showErrorAndFinish();
    return;
  }
  setVisible(false);
  mWebView=new WebView(this);
  mHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      super.handleMessage(msg);
      if (msg.what == LicenseFileLoader.STATUS_OK) {
        String text=(String)msg.obj;
        showPageOfText(text);
      }
 else {
        showErrorAndFinish();
      }
    }
  }
;
  CharSequence title=getText(R.string.settings_license_activity_title);
  CharSequence msg=getText(R.string.settings_license_activity_loading);
  ProgressDialog pd=ProgressDialog.show(this,title,msg,true,false);
  pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  mSpinnerDlg=pd;
  Thread thread=new Thread(new LicenseFileLoader(fileName,mHandler));
  thread.start();
}
 

Example 39

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: WebFragment.java

  15 
vote

@Override public View onCreateView(final LayoutInflater inflater,final ViewGroup container,final Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  final View v=inflater.inflate(R.layout.fragment_webview,container,false);
  webview=(WebView)v.findViewById(R.id.webview);
  final WebSettings settings=webview.getSettings();
  settings.setJavaScriptEnabled(true);
  settings.setDomStorageEnabled(true);
  settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
  settings.setSupportZoom(true);
  settings.setBuiltInZoomControls(true);
  settings.setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
  final View loading=v.findViewById(R.id.loading);
  webview.setWebViewClient(new WebViewClient(){
    @Override public void onPageFinished(    final WebView view,    final String url){
      loading.setVisibility(View.GONE);
    }
  }
);
  webview.loadUrl(url);
  return v;
}
 

Example 40

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/.

Source file: AccountCreateActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.account_create);
  webView=(WebView)findViewById(R.id.wvCreateAccount);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.setWebViewClient(new AccountCreateWebViewClient());
  ActivityUtil.startProgressBar(this);
  webView.loadUrl("http://alarmnotificationservice.appspot.com/mobile/register");
}
 

Example 41

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/page/.

Source file: BibleView.java

  15 
vote

/** 
 * enter text selection mode
 */
@Override public void selectAndCopyText(LongPressControl longPressControl){
  Log.d(TAG,"enter text selection mode");
  if (CommonUtils.isJellyBeanPlus()) {
    Log.d(TAG,"keycode Enter for JB+");
    KeyEvent enterEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_ENTER,0,0);
    longPressControl.ignoreNextLongPress();
    enterEvent.dispatch(this);
  }
 else {
    try {
      Log.d(TAG,"selectText for ICS");
      WebView.class.getMethod("selectText").invoke(this);
    }
 catch (    Exception e1) {
      try {
        Log.d(TAG,"emulateShiftHeld");
        Method m=WebView.class.getMethod("emulateShiftHeld",(Class[])null);
        m.invoke(this,(Object[])null);
      }
 catch (      Exception e2) {
        Log.d(TAG,"shiftPressEvent");
        KeyEvent shiftPressEvent=new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
        shiftPressEvent.dispatch(this);
      }
    }
  }
}
 

Example 42

From project Android, under directory /AndroidNolesCore/src/fragment/.

Source file: BrowserDetailFragment.java

  15 
vote

@Override public void onActivityCreated(Bundle savedInstanceState){
  super.onActivityCreated(savedInstanceState);
  setHasOptionsMenu(true);
  mWebView=(WebView)getView().findViewById(R.id.webview);
  mWebView.getSettings().setSupportZoom(true);
  mWebView.getSettings().setBuiltInZoomControls(true);
  mWebView.setWebChromeClient(new WebChromeClient(){
    public void onProgressChanged(    WebView view,    int newProgress){
      final ProgressBar progress=(ProgressBar)getView().findViewById(R.id.empty_loading);
      progress.setProgress(newProgress);
      progress.setVisibility(View.VISIBLE);
      if (newProgress == 100) {
        progress.setVisibility(View.GONE);
      }
    }
  }
);
  mWebView.setWebViewClient(new WebViewClient(){
    public void onReceivedError(    WebView view,    int errorCode,    String description,    String failingUrl){
    }
  }
);
  mWebView.loadUrl(getArguments().getString("url"));
}
 

Example 43

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: WebViewActivity.java

  15 
vote

@Override public void onPageFinished(WebView view,String url){
  super.onPageFinished(view,url);
  if (!mFirstPageLoaded) {
    if (url.startsWith("what:"))     return;
    mWebView.clearHistory();
    mFirstPageLoaded=true;
    activity.setTitleButtonEnabled("refresh",true);
    return;
  }
}
 

Example 44

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: HelpActivity.java

  15 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.help);
  webView=(WebView)findViewById(R.id.help_contents);
  webView.setWebViewClient(new HelpClient(this));
  Intent intent=getIntent();
  String page=intent.getStringExtra(REQUESTED_PAGE_KEY);
  View doneButton=findViewById(R.id.done_button);
  doneButton.setOnClickListener(doneListener);
  if (page.equals(DEFAULT_PAGE)) {
    doneButton.setVisibility(View.VISIBLE);
  }
 else {
    doneButton.setVisibility(View.GONE);
  }
  if (icicle != null && icicle.getBoolean(WEBVIEW_STATE_PRESENT,false)) {
    webView.restoreState(icicle);
  }
 else   if (intent != null && page != null && page.length() > 0) {
    webView.loadUrl(BASE_URL + page);
  }
 else {
    webView.loadUrl(BASE_URL + DEFAULT_PAGE);
  }
}
 

Example 45

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: PingServerActivity.java

  15 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.viewpingserver);
  ipAddress=(String)this.getIntent().getExtras().get("ipAddress");
  String urlWIp=getUrl(ipAddress);
  pingSiteView=(WebView)findViewById(R.id.ping_server_webview);
  pingSiteView.getSettings().setJavaScriptEnabled(true);
  pingSiteView.loadUrl(urlWIp);
}
 

Example 46

From project Android_1, under directory /FixedSizeTextColumns/src/com/novoda/.

Source file: HelloWebView.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.webview_main);
  webView=(WebView)findViewById(R.id.webview_main);
  webView.loadUrl("file:///android_asset/two_columns.html");
  fontSize=webView.getSettings().getDefaultFontSize();
  if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
    webView.setOnTouchListener(touchListener);
    zoomDetector=new PinchZoomDetector();
  }
}
 

Example 47

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/.

Source file: BulletinFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  ViewGroup root=(ViewGroup)inflater.inflate(R.layout.fragment_webview_with_spinner,null);
  root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT));
  mLoadingSpinner=root.findViewById(R.id.loading_spinner);
  mWebView=(WebView)root.findViewById(R.id.webview);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.post(new Runnable(){
    public void run(){
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
      mWebView.loadUrl(BULLETIN_URL);
    }
  }
);
  return root;
}
 

Example 48

From project BazaarUtils, under directory /src/com/congenialmobile/adad/.

Source file: AdView.java

  15 
vote

@Override public void onPageFinished(WebView view,String url){
  super.onPageFinished(view,url);
  if (url.toLowerCase().endsWith("noads") || url.toLowerCase().endsWith("noads/")) {
    mVisible=false;
    mHandler.post(updateUI);
  }
 else {
    mVisible=true;
    mHandler.post(updateUI);
  }
}
 

Example 49

From project BBC-News-Reader, under directory /src/com/digitallizard/bbcnewsreader/fragments/.

Source file: ArticleFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.article,container,false);
  loadingText=(TextView)view.findViewById(R.id.articleLoadingText);
  webView=(WebView)view.findViewById(R.id.articleWebView);
  webView.loadDataWithBaseURL(null,"Please select an article.","text/html","utf-8",null);
  return view;
}
 

Example 50

From project box-android-sdk, under directory /BoxAndroidLibrary/src/com/box/androidlib/activities/.

Source file: BoxAuthentication.java

  15 
vote

/** 
 * Load the login webview.
 * @param ticket Ticket from Box API action get_ticket
 */
private void loadLoginWebview(final String ticket){
  String loginUrl=BoxConstants.LOGIN_URL + ticket;
  mLoginWebView=(WebView)findViewById(R.id.loginWebView);
  mLoginWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
  mLoginWebView.getSettings().setJavaScriptEnabled(true);
  mLoginWebView.setWebViewClient(new WebViewClient(){
    @Override public void onPageFinished(    final WebView view,    final String url){
      getAuthToken(ticket,0);
    }
    @Override public boolean shouldOverrideUrlLoading(    final WebView view,    final String url){
      if (url != null && url.startsWith("market://")) {
        try {
          view.getContext().startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(url)));
          return true;
        }
 catch (        ActivityNotFoundException e) {
        }
      }
      return false;
    }
  }
);
  mLoginWebView.loadUrl(loginUrl);
}
 

Example 51

From project conference-mobile-app, under directory /android-app/src/com/google/android/apps/iosched/ui/.

Source file: BulletinFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  ViewGroup root=(ViewGroup)inflater.inflate(R.layout.fragment_webview_with_spinner,null);
  root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT));
  mLoadingSpinner=root.findViewById(R.id.loading_spinner);
  mWebView=(WebView)root.findViewById(R.id.webview);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.post(new Runnable(){
    public void run(){
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
      mWebView.loadUrl(BULLETIN_URL);
    }
  }
);
  return root;
}
 

Example 52

From project daily-money, under directory /dailymoney/src/com/bottleworks/dailymoney/ui/.

Source file: AboutActivity.java

  15 
vote

@Override protected void onCreate(Bundle bundle){
  super.onCreate(bundle);
  setContentView(R.layout.about);
  whatsnew=(WebView)findViewById(R.id.about_whatsnew);
  aboutapp=(WebView)findViewById(R.id.about_app);
  whatsnew.getSettings().setAllowFileAccess(true);
  whatsnew.getSettings().setJavaScriptEnabled(true);
  whatsnew.addJavascriptInterface(new JSCallHandler(),"dmctrl");
  whatsnew.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  aboutapp.getSettings().setAllowFileAccess(true);
  aboutapp.getSettings().setJavaScriptEnabled(true);
  aboutapp.addJavascriptInterface(new JSCallHandler(),"dmctrl");
  aboutapp.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  whatsnew.loadUrl(Constants.LOCAL_URL_PREFIX + i18n.string(R.string.path_what_is_new));
  aboutapp.loadUrl(Constants.LOCAL_URL_PREFIX + i18n.string(R.string.path_about_app));
}
 

Example 53

From project dccsched, under directory /src/com/underhilllabs/dccsched/ui/.

Source file: MapActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_map);
  ((TextView)findViewById(R.id.title_text)).setText(getTitle());
  showLoading(true);
  mWebView=(WebView)findViewById(R.id.webview);
  mWebView.post(new Runnable(){
    public void run(){
      if (CLEAR_CACHE_ON_LOAD) {
        mWebView.clearCache(true);
      }
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
      mWebView.setWebChromeClient(new MapWebChromeClient());
      mWebView.setWebViewClient(new MapWebViewClient());
      mWebView.loadUrl(MAP_URL);
      mWebView.addJavascriptInterface(new MapJsiImpl(),MAP_JSI_NAME);
    }
  }
);
}
 

Example 54

From project dcnyc10-android, under directory /android/src/com/lullabot/android/apps/iosched/ui/.

Source file: BulletinFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  ViewGroup root=(ViewGroup)inflater.inflate(R.layout.fragment_webview_with_spinner,null);
  root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT));
  mLoadingSpinner=root.findViewById(R.id.loading_spinner);
  mWebView=(WebView)root.findViewById(R.id.webview);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.post(new Runnable(){
    public void run(){
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
      mWebView.loadUrl(BULLETIN_URL);
    }
  }
);
  return root;
}
 

Example 55

From project devoxx-france-android-in-fine, under directory /src/com/infine/android/devoxx/ui/.

Source file: MapFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  ViewGroup root=(ViewGroup)inflater.inflate(R.layout.fragment_webview_with_spinner,null);
  root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT));
  mLoadingSpinner=root.findViewById(R.id.loading_spinner);
  mWebView=(WebView)root.findViewById(R.id.webview);
  mWebView.setWebChromeClient(mWebChromeClient);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.post(new Runnable(){
    public void run(){
      if (CLEAR_CACHE_ON_LOAD) {
        mWebView.clearCache(true);
      }
      mWebView.getSettings().setJavaScriptEnabled(true);
      mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
      mWebView.loadUrl(MAP_URL);
      mWebView.addJavascriptInterface(mMapJsiImpl,MAP_JSI_NAME);
    }
  }
);
  return root;
}
 

Example 56

From project DiscogsForAndroid, under directory /src/com/discogs/activities/.

Source file: WebActivity.java

  15 
vote

private void init(){
  progressBar=(ProgressBar)findViewById(R.id.progressBar);
  webView=(WebView)findViewById(R.id.webView);
  webView.setWebViewClient(new HelloWebViewClient());
  WebSettings settings=webView.getSettings();
  settings.setUserAgentString("desktop");
  settings.setJavaScriptEnabled(true);
  settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
  settings.setBuiltInZoomControls(true);
  settings.setSupportZoom(true);
  settings.setSaveFormData(true);
  settings.setSavePassword(true);
  String authUrl=getIntent().getExtras().getString("authUrl");
  webView.loadUrl(Uri.parse(authUrl).toString());
}
 

Example 57

From project droidkit, under directory /src/org/droidkit/app/.

Source file: UpdateActivity.java

  15 
vote

@Override public void onCreate(Bundle savedInstanceState){
  setTheme(android.R.style.Theme_Light_NoTitleBar);
  super.onCreate(savedInstanceState);
  setContentView(Resources.getId(this,"activity_update",Resources.TYPE_LAYOUT));
  bindService(new Intent(this,UpdateService.class),mConnection,BIND_AUTO_CREATE);
  mServiceRunning=true;
  mIconView=(ImageView)findViewById(Resources.getId(this,"update_act_icon",Resources.TYPE_ID));
  mTitleView=(TextView)findViewById(Resources.getId(this,"update_act_title",Resources.TYPE_ID));
  mAuthorView=(TextView)findViewById(Resources.getId(this,"update_act_author",Resources.TYPE_ID));
  mVersionView=(TextView)findViewById(Resources.getId(this,"update_act_ver",Resources.TYPE_ID));
  mDownloadLabel=(TextView)findViewById(Resources.getId(this,"update_act_dl",Resources.TYPE_ID));
  mNotesView=(WebView)findViewById(Resources.getId(this,"update_act_relnotes",Resources.TYPE_ID));
  mIconView.setImageResource(getApplicationInfo().icon);
  mProgressUpdate=(ProgressBar)findViewById(Resources.getId(this,"update_act_bar",Resources.TYPE_ID));
  mCloseButton=(Button)findViewById(Resources.getId(this,"update_act_cancel",Resources.TYPE_ID));
  mCloseButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      UpdateActivity.this.finish();
    }
  }
);
  mUpdateButton=(Button)findViewById(Resources.getId(this,"update_act_inst",Resources.TYPE_ID));
  mUpdateButton.setOnClickListener(mUpdateClick);
  try {
    String obj=getIntent().getStringExtra("json");
    JSONObject json=new JSONObject(obj);
    mTitleView.setText(json.getString("title"));
    mAuthorView.setText(json.getString("author"));
    JSONArray updates=json.getJSONArray("updates");
    JSONObject update=updates.getJSONObject(0);
    mNotesView.loadData(update.getString("release.notes"),"text/html","utf-8");
    mApkFile=update.getString("apk.url");
    mVersionView.setText("Version: " + update.getString("version.string"));
    Log.i("DroidKit","HTML: " + update.getString("release.notes"));
  }
 catch (  JSONException e) {
    Log.e("DroidKit","Error parsing the update JSON.");
  }
}
 

Example 58

From project empub, under directory /src/com/commonsware/empub/.

Source file: ChapterFragment.java

  15 
vote

@Override public boolean shouldOverrideUrlLoading(WebView view,String url){
  if (url.startsWith(EmPubActivity.CONTENT_PREFIX)) {
    ((NavListener)getActivity()).onInternalLinkClicked(url);
  }
 else {
    ((NavListener)getActivity()).onExternalLinkClicked(url);
  }
  return (true);
}