guys, is it safe to use google chrome tabs to repl...
# android
m
guys, is it safe to use google chrome tabs to replace webviews?
g
Yes, it’s safe. It will be handled by CustomTabs SDK
m
oh ok nice
thanks
g
actually, CustomTabs generates completely valid android.intent.action.VIEW intent with additional arguments that works fine without custom tabs
m
what if user has unninstalled chrome=?
is that possible
g
There isn’t any chrome dependencies, it’s just view intent with additional params
you can decompile android.support.customtabs.CustomTabsIntent and check arguments of intent
m
ok
thanks
i think
i disabled chrome in the settings
and now it crashes ..
g
Are you sure that you restarted app? Maybe it’s some cached intent
m
i didnt restart. 1s
g
or maybe you have no any other browser in your system
s
AFAIK you do have to do a check if chrometabs is available before using
m
restarted the app
still crashes
well in that case, i’ll use a custom library
dont want to handle multiple scenarios
g
Do you have any browser on your device except chrome?
m
dont think i have
1s
g
Any application will crash with or without customtabs if you try to open VIEW intent for URL without browser
s
looks like the check is only for SDK_INT
m
i emailed myself with a url, and it wont open
doesnt crash either, just dont open
g
Custom tabs available starting from api level 16
so if your target API is 16 or greater you shouldn’t check
just dont open
because your email app checks for intent
m
ok
g
There are two ways: 1. launch and forget, in case if user have no browser or other application, that handles such links, your app will crash. 2. Check each external intent. There is API for that
m
so i need to check for a viable browser then
sounds reasonable
g
If you want, most application actually never do that. But it make sense of course
m
gona try install another browser other than chrome and try
you right
firefox opens the tabs as well
i tought tabs were related to chrome and wud only work with chrome
g
To check you need something like:
Copy code
customTabBuilder.build().intent.resolveActivity(context.packageManager) != null
but as I said, this check not related to custom tabs, it’s universal thing for Android and any external intent
m
sounds logic
there a weird toast that shws up everytime user leaves the chrome tab and return to the app
something like “history stack was cleared”.
g
Looks like some sort of “incognito mode” in browser, but actually never saw this message
a
in fact it’s possible user device don’t have chrome installed (just come china and you will find it’s quite a lot since this country block Google and a serious of related app. The stock rom of Android device has its custom rom, without anything related to Google
And if anyone want to make sure use ChromeCustomTab right and safe, the fallback solution should be considered
m
doesn’t need to have chrome. it runs on another browsers isnt it?
i tried disabling chrome and it crashed. then installed firefox and it run
a
yeah it don’t really require chrome, it’s
intend
actually. I just tried it today morning, using a made in china mobile phone
And you can find some real nice library as I remember, there is a CustomTabHelper lib on github (may not exactly that name and you can search
m
i’ll leave it with chrome tabs for now
latter i’ll switch to a custom library like finnestwebview
thanks for you help tho
g
@anthonyeef But fallback solution already there! Right inside CustomTabs SDK. In case of no chrome or disabled custom tabs will be opened any exisitng browser.
@myanmarking Not any browser, but browser that supports custom tabs protocol. Not all browsers support it. And even if user has any browser or any other app that registered handler for http/https links this app will be opened if you use custom tabs
a
@gildor you are right
r
A great discussion!!