Merge branch 'master' of https://github.com/YumengNevix/flutter_inappwebview into YumengNevix-master
This commit is contained in:
commit
828cc7d434
|
@ -165,8 +165,16 @@ public class ChromeCustomTabsActivity extends Activity implements Disposable {
|
|||
@Nullable Map<String, String> headers,
|
||||
@Nullable String referrer,
|
||||
@Nullable List<String> otherLikelyURLs) {
|
||||
launchUrlWithSession(customTabsSession, url, headers, referrer, otherLikelyURLs);
|
||||
}
|
||||
|
||||
public void launchUrlWithSession(@Nullable CustomTabsSession session,
|
||||
@NonNull String url,
|
||||
@Nullable Map<String, String> headers,
|
||||
@Nullable String referrer,
|
||||
@Nullable List<String> otherLikelyURLs) {
|
||||
mayLaunchUrl(url, otherLikelyURLs);
|
||||
builder = new CustomTabsIntent.Builder(customTabsSession);
|
||||
builder = new CustomTabsIntent.Builder(session);
|
||||
prepareCustomTabs();
|
||||
|
||||
CustomTabsIntent customTabsIntent = builder.build();
|
||||
|
@ -328,7 +336,17 @@ public class ChromeCustomTabsActivity extends Activity implements Disposable {
|
|||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
customTabActivityHelper.bindCustomTabsService(this);
|
||||
boolean isBindSuccess = customTabActivityHelper.bindCustomTabsService(this);
|
||||
|
||||
if (!isBindSuccess) {
|
||||
// chrome process not running, start tab directly
|
||||
|
||||
if (initialUrl != null) {
|
||||
launchUrlWithSession(null, initialUrl, initialHeaders, initialReferrer, initialOtherLikelyURLs);
|
||||
//avoid webpage reopen: onServiceConnected->launchUrl
|
||||
initialUrl = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -122,14 +122,14 @@ public class CustomTabActivityHelper implements ServiceConnectionCallback {
|
|||
* Binds the Activity to the Custom Tabs Service.
|
||||
* @param activity the activity to be binded to the service.
|
||||
*/
|
||||
public void bindCustomTabsService(Activity activity) {
|
||||
if (mClient != null) return;
|
||||
public boolean bindCustomTabsService(Activity activity) {
|
||||
if (mClient != null) return true;
|
||||
|
||||
String packageName = CustomTabsHelper.getPackageNameToUse(activity);
|
||||
if (packageName == null) return;
|
||||
if (packageName == null) return false;
|
||||
|
||||
mConnection = new ServiceConnection(this);
|
||||
CustomTabsClient.bindCustomTabsService(activity, packageName, mConnection);
|
||||
return CustomTabsClient.bindCustomTabsService(activity, packageName, mConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue