Skip to content

Commit

Permalink
fix(android): make openUrl open apps that don't handle VIEW intents (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Aug 27, 2019
1 parent d152d87 commit 1e8d98a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/plugin/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,24 @@ public void openUrl(PluginCall call) {
return;
}

JSObject ret = new JSObject();
final PackageManager manager = getContext().getPackageManager();
final Intent launchIntent = new Intent(Intent.ACTION_VIEW);
Intent launchIntent = new Intent(Intent.ACTION_VIEW);
launchIntent.setData(Uri.parse(url));

try {
getActivity().startActivity(launchIntent);
ret.put("completed", true);
} catch(Exception ex) {
call.error("Unable to open url", ex);
launchIntent = manager.getLaunchIntentForPackage(url);
try {
getActivity().startActivity(launchIntent);
ret.put("completed", true);
} catch(Exception expgk) {
ret.put("completed", false);
}
}
call.success(ret);
}

/**
Expand Down

0 comments on commit 1e8d98a

Please sign in to comment.