コード例 #1
0
 private void openInBrowser(final String urlString) {
   final Intent intent = new Intent(Intent.ACTION_VIEW);
   final boolean externalUrl;
   if (BookDownloader.acceptsUri(Uri.parse(urlString))) {
     intent.setClass(BaseActivity, BookDownloader.class);
     intent.putExtra(
         BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
     externalUrl = false;
   } else {
     externalUrl = true;
   }
   final NetworkLibrary nLibrary = NetworkLibrary.Instance();
   new Thread(
           new Runnable() {
             public void run() {
               if (!urlString.startsWith("fbreader-action:")) {
                 nLibrary.initialize();
               }
               intent.setData(Uri.parse(nLibrary.rewriteUrl(urlString, externalUrl)));
               BaseActivity.runOnUiThread(
                   new Runnable() {
                     public void run() {
                       try {
                         BaseActivity.startActivity(intent);
                       } catch (ActivityNotFoundException e) {
                         e.printStackTrace();
                       }
                     }
                   });
             }
           })
       .start();
 }
コード例 #2
0
 private void openInBrowser(String urlString) {
   final Intent intent = new Intent(Intent.ACTION_VIEW);
   boolean externalUrl = true;
   if (BookDownloader.acceptsUri(Uri.parse(urlString))) {
     intent.setClass(myBaseActivity, BookDownloader.class);
     intent.putExtra(
         BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
     externalUrl = false;
   }
   final NetworkLibrary nLibrary = NetworkLibrary.Instance();
   try {
     nLibrary.initialize();
   } catch (ZLNetworkException e) {
   }
   intent.setData(Uri.parse(NetworkLibrary.Instance().rewriteUrl(urlString, externalUrl)));
   try {
     myBaseActivity.startActivity(intent);
   } catch (ActivityNotFoundException e) {
     // TODO: show an error message
   }
 }