Commit 4fb2bc13 authored by Jinsong Fan's avatar Jinsong Fan Committed by Commit Bot

AW: Fix exception for startActivity from outside of an Activity context

When WebView is initialized by non-activity context, startActivity will
cause runtime exception: lack the FLAG_ACTIVITY_NEW_TASK flag. Now, guard
it with activityFromContext null check.

Bug: 
Change-Id: Ia0ebf88f21d2064b734c0bbc9dc2636457e23321
Reviewed-on: https://chromium-review.googlesource.com/730041Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512730}
parent f52baea1
......@@ -210,6 +210,12 @@ public abstract class AwContentsClient {
// same application can be opened in the same tab.
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
// Check whether the context is activity context.
if (AwContents.activityFromContext(context) == null) {
Log.w(TAG, "Cannot call startActivity on non-activity context.");
return false;
}
try {
context.startActivity(intent);
} catch (ActivityNotFoundException ex) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment