How to hide the URL Of Custom Tab?

一笑奈何 提交于 2020-01-15 03:13:13

问题


I am using a custom tab in android. I have gone through many of the google search to hide the URL of custom tab but everywhere is showing that it is not possible to hide the URL.I just want to know that is there any way from which i can hide the url in custom tab.


回答1:


You could try this ugly solution which can do the trick while you don't get a better solution:

1) create an html document with this contents:

<frameset rows="100%">
     <frameset cols="100%">
          <frame src="http://192.169.218.96:7777" frameborder="0">
     </frameset>
</frameset>

2) save this on your ASSETS folder (same level as RES and not inside it). Trying to illustrate this:

+ src
++ main
+++ assets
+++ java
+++ res

3) make your customTab load this asset instead of the original url (you could implement a connectivity detector here to show alternative content if internet is not present).

EDIT: 4) then use this string on your custom tab loading method (considering you saved your frameset html with name of name.html):

String loadPage = "file:///android_asset/name.html";

Do not use the common html, head, body (and so on) tags, just what I've showed above.

Old but fully compliant with W3C and browsers solution. Details: https://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#h-16.2.1



来源:https://stackoverflow.com/questions/44213314/how-to-hide-the-url-of-custom-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!