WebView vs Chrome Custom Tab - android

I am building an app where in a Detail Activity I have to show a web page.
I was going to use WebView, but then I saw Chrome Custom Tab.
What do you guys think it's better to implement and why?

If you just want to show a certain page then I would suggest you use chrome custom tabs. You can style the toolbar in a way it resembles your app style and they are intended for showing content without you having to worry much about anything else.
if you want to have full control over what the user is doing inside this website you have to use a webview. (you can prevent the user clicking links on the webview, you could intercept data the user inputs into controls on the website...)
But this can also be a negative aspect since the user really has to trust you that you don't log his data or even fiddle with it.
summary: "The WebView is good solution if you are hosting your own content inside your app. If your app directs people to URLs outside your domain, we recommend that you use Chrome Custom Tabs"
-> If it isn't your website you probably should go with custom tabs.
https://developer.chrome.com/multidevice/android/customtabs#whentouse

Webview : If you want your own content which has click listeners and data interception you need to go to webview. But It wont share the state with the browser.
Chrome Custom tab : If You are just redirecting to a url, i prefer chrome custom tab. But it has little cons too. We wont change its title text color where we can change the titlebar color. The text color will be chosen by the theme color only. And We can add actions, but we cant change the overflow menu icon or the entire actions displayed in the overflow action.
Even though the limitation are not a big deal. I recommend chrome custom tab over webview.

Related

android : Customize dropdown's radiobutton open from webview

I am developing android application which is based on the webview.
The page loaded in the WebView has dropdown. When I click on the drop down, a dialog appears(it is the native Android dialog).i want to apply my them for that dropdown dialog item. i have searched but solution not found for that.
FYI, I have implemented it in the native activity but not able to implement it in webview.I want dropdown alert like displayed in below image.
Please help me, if anyone knows related to this issue.
You need to understand the concept of a Webview. It is just like a browser which you are loading inside your activity. Your other activities in the app can not interact with the webview. If you want to change the style of your dropdown for android's webview, use Media Queries in your website which will change the view of your website when loaded for smaller devices

How to open a webview over current layout in Android?

Been searching for this for a while. How do I open a webview that will appear on top of my current layout ? The webview will show a webpage from the internet where users enter their details and submit it.
If anyone has played with Facebook login, Twitter login, or even PayPal payment, they are all doing exactly what I want, a webview floating on top of the current layout please see the screenshot below:
please note, I will not create my own webview textboxes and buttons, it will be a webpage from a url that I wish to display in that webview
Just launch it in a Dialog.
Dialogs can be themed with custom layouts to look like pretty much anything.
If you still need more flexibility, try using a dialog themed Activity.

Android - webview removing header and footer displaying only selected contents

i need to convert a complete website into an android app. But I don't want the header, menu and footer in every page to be displayed.
Is there any way I can just take the content of the webpage alone and display in web view.?
Thanks.
If you are using joomla...i have a solution that worked for me....
Go to template settings, hide the logo, menu and footer section
In your app you wll not see any header, footer and logo
Do you have control over the website's source? If yes, it is much easier to write a css-file for mobiles (and use JS to detect the UserAgent) than to do any of that work in the mobile app itself.
However, if you really want to mess with the page on your device, you can extract the html-source, change it (delete the header+menu+footer), and load that changed source into the webview.

WebView / App Label Interactions

I am doing some pretty basic html displays using WebView and all is working well. One thing that I would like to do is as the user navigates between pages update the application label. I believe I'm calling it the correct name as Application label. This is the area where your string app_name is displayed via the manifest.
So anyway I would like to update it to say the tag of each page but I am not sure where to begin researching that type of interaction if it's possible. The other option as I've seen others do, but don't know how is to get my WebView to cover the application label area..or remove it or whatever it is they do. Once removed I'll just add a to my page displaying the .
TIA
JB
This is the area where your string app_name is displayed via the manifest.
My guess is that you are referring to the title bar (on older devices) or the action bar (on newer devices, plus older devices using ActionBarSherlock).
You can modify the text displayed there by calling setTitle() in your activity.

How do you create the Browser layout (search bar on top, webview on bottom)?

I'm trying to mimic the default android Browser app layout, which has a "search_bar" on top and then a "webview" right below it. The user can scroll both items up, all the while the scroll bar only appears to the right of the webview (not both the webview and the search bar).
I've tried putting both the webview and the searchbar into a scrollview, but this shows the scrollbar next to the search_bar.
If you need to mimic the exact layout of default browser have a look at it's source code:
Where can I find Android source code online?
If you need only browser source have a look here:
https://android.googlesource.com/platform/packages/apps/Browser
From what I can see (a quick look at it) it is more complicated layout, but you may start analysing it from:
Browser\res\layout\browser_subwindow.xml
which directly includes WebView. This file is directly loaded by Tab... Go ahaed and analyse it on your own it is pretty simple as it is a regular Android application.
Hope it helps.

Categories

Resources