Skip to content

Commit

Permalink
Merge pull request gree#834 from gree/fix/startactivity
Browse files Browse the repository at this point in the history
fixed to invoke startActivity() without queryIntentActivities() (for Android 11 or later.)
  • Loading branch information
KojiNakamaru authored Aug 19, 2022
2 parents 665e3ff + 4823f61 commit 071f109
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package net.gree.unitywebview;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -440,9 +441,13 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PackageManager pm = a.getPackageManager();
List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
if (apps.size() > 0) {
// List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
// if (apps.size() > 0) {
// view.getContext().startActivity(intent);
// }
try {
view.getContext().startActivity(intent);
} catch (ActivityNotFoundException ex) {
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.Manifest;
import android.app.Activity;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -609,10 +610,14 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PackageManager pm = a.getPackageManager();
List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
if (apps.size() > 0) {
// PackageManager pm = a.getPackageManager();
// List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0);
// if (apps.size() > 0) {
// view.getContext().startActivity(intent);
// }
try {
view.getContext().startActivity(intent);
} catch (ActivityNotFoundException ex) {
}
return true;
}
Expand Down

0 comments on commit 071f109

Please sign in to comment.