Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Licensed to the Apache Software Foundation (ASF) under one

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -1190,6 +1189,16 @@ public boolean shouldOverrideUrlLoading(WebView webView, String url) {
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest request) {

String url = request.getUrl().toString();

if (url.matches(".*\\.(pdf|rtf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|mp3|mp4|mpg|mpeg|avi|wmv|mov|apk|odt|ods|txt|csv)(\\?.*)?$")) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
return true;
}

return shouldOverrideUrlLoading(request.getUrl().toString(), request.getMethod());
}

Expand Down
Loading