Hi I try to display pdf with webview. I set all codes properly but pdf didnt open. but I give a webpage link it works good. what is my mistake I am newbie sorry.
WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_giris);
wv = (WebView) findViewById(R.id.wv);
WebSettings webSettings = wv.getSettings();
wv.setWebViewClient(new WebViewClient());
wv.getSettings().setBuiltInZoomControls(true); //zoom yapılmasına izin verir
wv.getSettings().setSupportZoom(true);
// wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
materialDesignFAM = (FloatingActionMenu) findViewById(R.id.social_floating_menu);
floatingActionButton1 = (FloatingActionButton) findViewById(R.id.floating_facebook);
floatingActionButton2 = (FloatingActionButton) findViewById(R.id.floating_twitter);
floatingActionButton3 = (FloatingActionButton) findViewById(R.id.floating_linkdin);
floatingActionButton4 = (FloatingActionButton) findViewById(R.id.floating_google_plus);
floatingActionButton5 = (FloatingActionButton) findViewById(R.id.floating_instagram);
floatingActionButton6 = (FloatingActionButton) findViewById(R.id.floating_youtube);
floatingActionButton1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String fullPath = "http://aciltip.medicine.ankara.edu.tr/files/2015/09/2015_d45_acil_tip_hizmetleri.pdf";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullPath));
startActivity( browserIntent);
// wv.loadUrl("https://docs.google.com/gview?embedded=true&url=http://aciltip.medicine.ankara.edu.tr/files/2015/09/2015_d45_acil_tip_hizmetleri.pdf");
// String url = "http://www.example.com";
// startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
});
floatingActionButton2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
wv.loadUrl("http://docs.google.com/viewer?embedded=true&url=http://www.ctf.edu.tr/stek/pdfs/70/7001.pdf");
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
}
});
floatingActionButton3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
wv.loadUrl("http://docs.google.com/gview?embedded=true&url=http://www.ctf.edu.tr/stek/pdfs/70/7001.pdf");
}
});
and logcat is these:
03-07 08:50:26.577 3489-3547/com.er.ap D/EGL_emulation: eglCreateContext: 0xa3539fa0: maj 2 min 0 rcv 2 03-07 08:50:26.578 3489-3547/com.er.ap D/EGL_emulation: eglMakeCurrent: 0xa3539fa0: ver 2 0 03-07 08:50:27.446 3489-3489/com.er.ap I/chromium: [INFO:CONSOLE(0)] "The Content-Security-Policy directive 'base-uri' is implemented behind a flag which is currently disabled. ", source: https://accounts.google.com/o/oauth2/postmessageRelay?parent=https%3A%2F%2Fdocs.google.com&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_US.dLR0UQgpDEo.O%2Fm%3D__features__%2Fam%3DAQE%2Frt%3Dj%2Fd%3D1%2Frs%3DAGLTcCMdWrzahDTQIubih7dySWJqcBU_nw#rpctoken=580516055&forcesecure=1 (0)
But below works good as my will but it quits my apps and go to the pdf url and my back button disapper. if anyone help me this issue. it will be very usefull for me
floatingActionButton1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String fullPath = "https://drive.google.com/open?id=0B16f9Z9VbJmCc3RhcnRlcl9maWxl";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fullPath));
startActivity( browserIntent);
});