Custom Tabs is one of the ways as @pRaNaY mentioned. Here is a quick implementation:
private static final String EXTRA_CUSTOM_TABS_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR";
private static final String PACKAGE_NAME = "com.android.chrome";
private CustomTabsClient mClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
warmUpChrome();
launchUrl();
}
private void warmUpChrome() {
CustomTabsServiceConnection service = new CustomTabsServiceConnection() {
@Override
public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) {
mClient = client;
mClient.warmup(0);
}
@Override
public void onServiceDisconnected(ComponentName name) {
mClient = null;
}
};
CustomTabsClient.bindCustomTabsService(getApplicationContext(),PACKAGE_NAME, service);
}
private void launchUrl() {
Uri uri = getIntent().getData();
if (uri == null) {
return;
}
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
customTabsIntent.intent.setData(uri);
customTabsIntent.intent.putExtra(EXTRA_CUSTOM_TABS_TOOLBAR_COLOR, getResources().getColor(R.color.red));
PackageManager packageManager = getPackageManager();
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(customTabsIntent.intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resolveInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
if (TextUtils.equals(packageName, PACKAGE_NAME))
customTabsIntent.intent.setPackage(PACKAGE_NAME);
}
customTabsIntent.launchUrl(this, uri);
}
Gradle:
compile "com.android.support:customtabs:23.0.0"
Additional Notes:
Calling warmUpChrome as early as possible will make the switch to the browser faster. The implementation in the example works with deeplinks, but if you want to launch it manually rewrite launchUrl and give a URI or a String as a parameter. The code is mostly stitched together from other stackoverflow answsers, but I have changed some parts of it to work for my case.