27

I have implemented new Chrome Custom Tab in android, I am using the following code to open

Uri uri = Uri.parse("https://akash.plobal.com/ploicy");
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();                   
intentBuilder.setToolbarColor(Color.BLACK);
intentBuilder.setShowTitle(true);
intentBuilder.build().launchUrl(getActivity(), uri);

I need to hide url below the title in toolbar

enter image description here

Akash Doshi
  • 421
  • 1
  • 4
  • 8

3 Answers3

27

If you control both the content and the application, you can use Trusted Web Activities to completely remove the URL bar. You'll need to implement Digital Asset Links to validate the ownership of both.

If you don't own the content, it is not possible to hide the URL below the title. The URLs needs to visible to the user, so that they can know in which site they are. By removing this from the UI, a malicious site could mimic the UI of another one, and this could potentially create a security issue for users.

andreban
  • 4,621
  • 1
  • 20
  • 49
  • 1
    Indeed, this is by design, and an important part of the security model of custom tabs. If you do not need access to the user's browser state (i.e. cookies, etc. that have already been set in their browser) you can use a [WebView](https://developer.android.com/reference/android/webkit/WebView.html) to display the contents of this page without any decoration. – iainmcgin Nov 15 '16 at 20:43
  • is there any way to hide the close button? – Ali Feb 15 '18 at 07:47
  • How can we change the title of the tab in xamarin.android? – Thamarai T Apr 22 '19 at 14:37
  • 3
    Good answer, but still we need a solution. Unfortunately, the Webview uses bad/outofdate/old engine that fails to display modern web-pages correctly, thus we need a solution to have the ability to display any web-page correctly, like the superb chrome engine. Shortly - So, is there any other solution to the problem ? – JamesC Nov 28 '19 at 19:05
  • Trusted Web Activities are now an option, if you own both the application and the content being opened. I have updated the answer. – andreban Nov 29 '19 at 10:29
-4

You cannot hide the url alone. You can only get rid of the whole title bar, that too when the user scroll the view. To achieve this,use

intentBuilder.enableUrlBarHiding();

devgun
  • 1,003
  • 13
  • 33
-7

You can try setShowTitle(false) of your custom tab.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Prashant Jajal
  • 3,469
  • 5
  • 24
  • 38