Skip to content

Commit

Permalink
Fixing a crash caused by a null URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
quanquan1 committed Feb 26, 2024
1 parent 09714fb commit 9c0e7ef
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Message;
import android.webkit.ConsoleMessage;
import android.webkit.JsResult;
import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

Expand All @@ -29,9 +30,12 @@ public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGest
Message resultMsg) {
final WebView.HitTestResult result = view.getHitTestResult();
final String data = result.getExtra();
final Context context = view.getContext();
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
context.startActivity(browserIntent);
if (isUserGesture && URLUtil.isNetworkUrl(data) && result.getType() == WebView.HitTestResult.SRC_ANCHOR_TYPE) {
final Context context = view.getContext();
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
context.startActivity(browserIntent);
return true;
}
return false;
}

Expand Down

0 comments on commit 9c0e7ef

Please sign in to comment.