Android - Wczytaj plik PDF do przeglądarki internetowej
Mam ten kod przeglądarki internetowej i chcę umożliwić otwieranie plików PDF, gdy użytkownik kliknie łącze PDF. Oto kod, czy możesz mi powiedzieć, co muszę umieścić w tym obszarze PDF? Próbowałem wielu różnych sposobów i nie mogę w ogóle wyświetlić pliku PDF. Dzięki za pomoc.
<code>webview.setWebViewClient ( new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { // do your handling codes here, which url is the requested url // probably you need to open that url rather than redirect: if (url.startsWith("tel:")) { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url))); } else if (url.startsWith("mailto:")) { url = url.replaceFirst("mailto:", ""); url = url.trim(); Intent i = new Intent(Intent.ACTION_SEND); i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[]{url}); startActivity(i); } else if (url.startsWith("geo:")) { try { } catch (Exception e) { System.out.println(e); } } else if (url.endsWith("pdf")) { try { } catch (Exception e) { System.out.println(e); } } else { view.loadUrl(url); } return true; // then it is not handled by default action } }); </code>