String url = "http://google.com"; String PACKAGE_NAME = "com.android.chrome"; CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().setShowTitle(true).build(); customTabsIntent.intent.setData(Uri.parse(url)); List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(customTabsIntent.intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resolveInfoList) { String packageName = resolveInfo.activityInfo.packageName; if(PACKAGE_NAME.equals(packageName)) customTabsIntent.intent.setPackage(PACKAGE_NAME); // force use chrome if installed } customTabsIntent.launchUrl(MainActivity.this, Uri.parse(url));
브라우저로 띄우니 back을 할 때 기존에 떠 있던 화면이 있으면 원하는 동작이 안나와서 찾아보니 이렇게 쉽게 쓸 수 있는 코드가 있다.
bind service 하는 코드는 특정 버전 이상의 크롬을 깔아야했는데, 이건 그렇진 않다.
도움받은 곳 : http://stackoverflow.com/a/32656019/1025379