Skip to content

Commit

Permalink
Fixed NullPointerException (getodk#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 authored and lognaturel committed Jun 25, 2018
1 parent d604f2a commit e9796dc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/**
* Created by sanjeev on 17/3/17.
*/

public class CustomTabHelper {
public static final String OPEN_URL = "url";
private static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome";
Expand All @@ -44,12 +43,15 @@ public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabs
CustomTabHelper.this.customTabsClient = customTabsClient;
CustomTabHelper.this.customTabsClient.warmup(0L);
customTabsSession = CustomTabHelper.this.customTabsClient.newSession(null);
customTabsSession.mayLaunchUrl(getNonNullUri(url), null, null);
if (customTabsSession != null) {
customTabsSession.mayLaunchUrl(getNonNullUri(url), null, null);
}
}

@Override
public void onServiceDisconnected(ComponentName name) {
customTabsClient = null;
customTabsSession = null;
}
};
CustomTabsClient.bindCustomTabsService(context, CUSTOM_TAB_PACKAGE_NAME, serviceConnection);
Expand All @@ -61,7 +63,6 @@ public void onServiceDisconnected(ComponentName name) {
* http://stackoverflow.com/a/33281092/137744
* https://medium.com/google-developers/best-practices-for-custom-tabs-5700e55143ee
*/

private List<String> getPackageName(Context context) {
// Get default VIEW intent handler that can view a web url.
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.test-url.com"));
Expand Down

0 comments on commit e9796dc

Please sign in to comment.