Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve error #706

Merged
merged 4 commits into from
Feb 28, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ boolean executeAction(@NonNull Context context, @Nullable IterableAction action,
* `false` if the handler did not handle this URL and no activity was found to open it with
*/
private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull IterableActionContext actionContext) {
boolean uriHandled = false;
// Handle URL: check for deep links within the app
if (!IterableUtil.isUrlOpenAllowed(uri.toString())) {
return false;
Expand All @@ -73,6 +74,11 @@ private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull Ite
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);

if (context.getPackageManager() == null) {
IterableLogger.e(TAG, "Could not find package manager to handle deep link:" + uri);
return false;
}

List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
if (resolveInfos.size() > 1) {
for (ResolveInfo resolveInfo : resolveInfos) {
Expand All @@ -88,11 +94,11 @@ private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull Ite

if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
return true;
uriHandled = true;
} else {
IterableLogger.e(TAG, "Could not find activities to handle deep link:" + uri);
return false;
}
return uriHandled;
}

/**
Expand Down
Loading