Below code written inside shouldOverrideUrlLoading(WebView view, String url) working on android 4.3 and below. but not working on android 4.4 (Kitkat). while debugging I found shouldOverrideUrlLoading() not called when I clicked on pdf link, but called on every link that not contain file.

if(url.contains(".pdf")){
    try{        
    Intent browserIntent = new Intent();
    browserIntent.setAction(Intent.ACTION_VIEW);
    browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
    browserIntent.setData(Uri.parse(url));
    startActivity(browserIntent);   
    }catch(){
    }   

Related posts

Recent Viewed