WebView App Documentation
WebView App Documentation
Documentation
Intro
This is a documentation for WebView App created by Robo Templates. WebView App is
a native Android application. You can find here useful info how to configure, customize,
build and publish your WebView App.
Features
WebView supports HTML5, JavaScript, Cookies, CSS, images, videos and other
standard web tools and technologies
Firebase Analytics
Intents for opening external apps (e-mail, sms, phone call, map, store, social networks)
Local pages (available in offline)
Fullscreen video
Download manager
Geolocation (optional)
Pull-to-Refresh (optional)
Ten color themes (blue, brown, gray, green, lime, orange, purple, red, teal, violet)
Offline handling
Error handling
Responsive design (portrait, landscape, handling orientation change)
RTL
Multi-language support
Deep links
Runtime permissions
Easy configuration
Well documented
Free support
This chapter describes how to install Android Studio and Android SDK. You don’t have
to install Android Studio, but it’s better. The project can be built without Android Studio,
using Gradle and Android SDK. Gradle is a build system used for building a final APK
file.
1. Install Java JDK
3. Run Android SDK Manager and download necessary SDK packages, make sure that you
have installed Android SDK Tools, Android SDK Platform-Tools, Android SDK Build-
Tools, Android Emulator and Google USB Driver
4. Now you should be able to open/edit the Android project and build an APK
Project Structure
Project has the following structure (directories are marked by square braces):
[doc] - documentation
[extras]/[keystore]
[gradle]
[mobile]/[src]/[main]
Java packages:
Configuration
This chapter describes how to configure the project to be ready for publishing. All these
steps are very important!
If you are stuck and need help, try to search the problem in comments on CodeCanyon.
Most of the problems have already been discussed so there is a good chance that you
will find the answer to your question there. You can also use Stack Overflow to find
answers to your technical questions, resolve issues and bugs.
1. Import
Unzip the package and import/open the project in Android Studio. Choose “Import
project” on Quick Start screen and select “webviewapp-x.y.z” directory.
You can switch to Project view in the Project window on left if you want to see the actual
file structure of the project including all files hidden from the Android view. Just select
Project from the dropdown at the top of the Project window.
If you want, you can build and run the app right away to test it. Connect your device
or emulator to your computer. Make sure you have installed all necessary drivers for
your Android device and you also enabled USB debugging in Developer options. To
build and run the app in Android Studio, just click on Main menu -> Run -> Run ‘mobile’.
Choose a connected device and confirm.
2. Set Purchase Code
Open configuration
file mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java and
set value of PURCHASE_CODE constant to your own Envato purchase code.
You are licensed to use this code to create one single end product for yourself or for one
client (a “single application”). If you want to publish more than one app on Google Play,
you have to buy more licenses. You have to buy a License for each end product. If you
are going to sell your app, you will have to buy an Extended License. The Extended
License is required if end user must pay to use end product. Please read the license
terms for more info.
3. Rename Application ID
Every Android app has a unique application ID. This ID uniquely identifies your app on
the device and in Google Play Store. If you want to upload a new version of your app,
the application ID (and the certificate you sign it with) must be the same as the original
APK. If you change the application ID, Google Play Store treats the APK as a completely
different app. So once you publish your app, you should never change the application
ID. Default application ID is “com.robotemplates.webviewapp” so you have to rename it
to something else.
2. If you try to build the project now, you will probably get “No matching client found for
package name…” error. The reason for this is that declared package names
in mobile/google-services.json don’t match to your own package name (application ID).
We will setup Firebase and google-services.json later. In the meantime, if you want to get
rid of the error, just update values of all package_name attributes in google-services.json to
your own package name (application ID), e.g. “com.mycompany.myapp”.
3. Synchronize the project. Main menu -> File -> Sync Project with Gradle Files.
Right click on mobile/src/main/res directory -> New -> Image Asset -> Icon Type
“Launcher Icons”, Name “ic_launcher”, create the icon as you wish, you can set clipart,
text, shape, color etc. -> Next -> Finish.
You can also change the logo shown in the navigation drawer header. It is stored
in mobile/src/main/res/drawable-nodpi/navigation_header_logo.png.
Theme.WebViewApp.Blue
Theme.WebViewApp.Brown
Theme.WebViewApp.Gray
Theme.WebViewApp.Green
Theme.WebViewApp.Lime
Theme.WebViewApp.Orange
Theme.WebViewApp.Purple
Theme.WebViewApp.Red
Theme.WebViewApp.Teal
Theme.WebViewApp.Violet
List of webview URLs. You can specify URL link to a web page on the Internet or URL
link to a local page stored in assets directory. Local page does not require Internet
connection. URL to the local page must be in this
format: file:///android_asset/example.html .
Use {FCM_REGISTRATION_TOKEN} or {ONE_SIGNAL_USER_ID} tags if you want to insert the
FCM registration token or the OneSignal user id. If you want to add a category, leave the
item empty. Menu item without URL is considered as a category item.
List of share messages. Each webview page can be shared via e-mail, sms, social
networks etc. Share button is in the action bar. You can specify a message which will be
posted. Use {TITLE} or {URL} tags if you want to insert a title or a URL link of the page. If
you don’t want to share the page, keep the item empty.
You can add/remove/modify menu items as you need. If you want to use local pages,
copy HTML files to mobile/src/main/assets directory and set proper paths
in navigation_url_list array. See the path format above.
Note: Main home page is the first page in the list of URLs. This page is loaded even if
the navigation drawer is disabled.
When user taps on a notification, the app is opened and home page is loaded. If you
want to load a specific page, you have to send the notification with additional data. Open
Firebase -> Cloud Messaging -> New message -> Additional options -> Custom data ->
set “url” as a key and your link as a value.
You can change the icon of push notification by replacing ic_stat_notification.png files
in drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi di
rectories.
Tip: You can target push notification messages on specific users by passing the FCM
registration token in the webview URL. See Setup Navigation and Web Pages chapter
for more info.
9. Setup OneSignal
There are 2 options how to send push notifications: via Firebase Console or using
OneSignal. If you prefer to use OneSignal, read following instructions, otherwise you can
skip this step and use just Firebase Console which is simpler.
When user taps on a notification, the app is opened and home page is loaded. If you
want to load a specific page, you have to send the notification with additional data.
Open OneSignal admin -> New Message -> Launch URL -> set the link. Other
alternative is New Message -> Advanced Settings -> Additional Data -> set “url” as a key
and the link as a value. Both variants have the same result - the app will be opened with
the specified URL.
You can also specify your test device id in admob_test_device_id string and use test
mode when you are debugging the app. Requesting test ads is recommended when you
are testing your application on a real device so you do not request invalid impressions.
You can find your hashed device id in Android Monitor (Logcat) output by requesting an
ad when debugging on your device. Open Android Monitor (Logcat) in Android Studio
and look for “To get test ads on this device, call
adRequest.addTestDevice(“XXXXXX…”);”. You can use filter/search to find this
information in the log. That XXX string is the hashed device id. This applies only to real
devices, not emulators. Emulators are considered as test devices by default so you don’t
have to care about it.
Interstitial ad will be shown after each x url loadings or clicks on the navigation drawer
menu. Frequency of showing AdMob interstitial ad can be changed. Open configuration
file mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java and
set value of ADMOB_INTERSTITIAL_FREQUENCY constant.
This app is GDPR (European Union’s General Data Protection Regulation) compliant.
GDPR consent form is shown to users located in the European Economic Area during
the first launch of the app. Users can choose if they want to personalize ads or not.
GDPR consent form requires a URL link to your privacy policy. You can specify the link
in GDPR_PRIVACY_POLICY_URL constant. Leave the constant empty if you don’t want to
show GDPR consent form. Empty means public static final String
GDPR_PRIVACY_POLICY_URL = "";. Privacy policy link should be also provided within the
app (e.g. in the navigation menu) because Google Play requires developers to provide a
valid privacy policy when the app requests or handles sensitive user or device
information (e.g. advertising identifier). You can use privacy policy generator.
Note: Sometimes happens that there is no ad shown in the app. There is nothing wrong,
it is correct behavior. If you see Failed to load ad: 0 in the log, it means that the ad is
newly created. It will take some time to fetch ads from Google servers. You just need to
wait a few hours. If you see Failed to load ad: 3 in the log, it means that your ad request
was successful but Google server was not able to provide any ads for the target user.
You need to create your own keystore to sign an APK/AAB file before publishing the app
on Google Play. You can create the keystore in Android Studio or via keytool utility.
1. Easiest way is to create the keystore directly in Android Studio. Main menu -> Build ->
Generate Signed Bundle / APK -> APK -> Create new. Keystore file name has to
be webviewapp.jks and must be stored in extras/keystore directory. After you create the
keystore file, you can just close the Generate Signed Bundle or APK dialog.
Note: If you want to create the keystore via keytool utility, run following
command: keytool -genkey -v -keystore webviewapp.jks -alias <your_alias> -keyalg
RSA -keysize 2048 -validity 36500 where <your_alias> is your alias name. For
example your company name or app name. Keytool utility is part of Java JDK. On
Windows, you can find it usually in C:\Program Files\Java\jdkX.Y.Z\bin. On Mac, you can
find it usually in /Library/Java/JavaVirtualMachines/jdkX.Y.Z/Contents/Home/bin. If you
create the keystore this way, don’t forget for step 2 and 3 above.
Important: Don’t lose the keystore file, otherwise you will not be able to publish new
updates on Google Play. You must use the same certificate throughout the lifespan of
your app in order for users to be able to install new versions as updates to the app.
Optionally, you can use Google Play App Signing to avoid losing your keystore.
Customization
Action Bar
You can enable/disable action bar (toolbar) in the configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set ACTION_BAR constant to true/false.
You can enable/disable navigation drawer menu in the configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set NAVIGATION_DRAWER constant to true/false.
You can enable/disable background image in the header of the navigation drawer menu.
Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set NAVIGATION_DRAWER_HEADER_IMAGE constant to true/false. If it is disabled, accent color
will be used for the background. Background image is stored
in mobile/src/main/res/drawable-nodpi/navigation_header_bg.png. Logo shown in the
header is stored in mobile/src/main/res/drawable-nodpi/navigation_header_logo.png.
Exit Confirmation
You can enable/disable exit confirmation dialog (when user tries to exit the app by
pressing the back button) in the configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set EXIT_CONFIRMATION constant to true/false.
Geolocation
Application supports geolocation. Keep in mind, that some users might have geolocation
disabled on their device. Geolocation requires a permission to access GPS. Permission
request is shown when it’s necessary. If user decides to reject the permission,
geolocation will not work. If you don’t use geolocation on your web, it is better to disable
it. You can enable/disable geolocation in the configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set GEOLOCATION constant to true/false.
Also keep in mind, that HTML5 geolocation is not allowed anymore with insecure HTTP
protocol for security reasons. It is recommended to use secure HTTPS protocol.
See Deprecating Powerful Features on Insecure Origins for more info.
Progress Placeholder
You can enable/disable progress placeholder (shown when loading a first page) in the
configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set PROGRESS_PLACEHOLDER constant to true/false.
JavaScript API
Application provides rich JavaScript API which you can use to interact with the mobile
app from your web using JavaScript. You can enable/disable JavaScript API in the
configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set JAVA_SCRIPT_API constant to true/false. It is recommended to disable the JavaScript
API if you don’t plan to use it for security reasons. JavaScript API provides following
JavaScript functions:
RoboTemplatesWebViewApp.showToast(message);
RoboTemplatesWebViewApp.showSnackbar(message);
RoboTemplatesWebViewApp.showSnackbarWithButton(message, button);
RoboTemplatesWebViewApp.showDialog(title, message);
RoboTemplatesWebViewApp.openBrowser(url);
RoboTemplatesWebViewApp.openStore();
RoboTemplatesWebViewApp.share(subject, text);
RoboTemplatesWebViewApp.closeApp();
RoboTemplatesWebViewApp.sendOneSignalTag(key, value);
RoboTemplatesWebViewApp.showInterstitialAd();
Pull-to-Refresh Gesture
You can enable/disable pull-to-refresh gesture in the configuration file. There are 3
modes.
Open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d set value of PULL_TO_REFRESH constant to ENABLED, DISABLED or PROGRESS. Set
ENABLED to enable the gesture, set DISABLED to disable the gesture, set PROGRESS
to disable the gesture and show only progress indicator.
Tip: If you have a problem with scrolling, try to disable the pull-to-refresh gesture. It
usually resolves any scrolling issues.
In-app Review Dialog
In-app review dialog is shown after each x url loadings or clicks on navigation drawer
menu.
Open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java file
if you want to configure the in-app review dialog. Frequency of showing the dialog can
be set in INAPP_REVIEW_DIALOG_FREQUENCY constant. Set frequency to 0 if you don’t want
to show the in-app review dialog. Keep in mind that the in-app review dialog might not
show up. It’s not guaranteed. Google Play enforces a time-bound quota on how often a
user can be shown the review dialog. Therefore in-app review dialog shouldn’t be shown
too often. See Google Play In-App Review API for more info.
Rate my app prompt dialog is shown after each x launches of the app.
Open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java file
if you want to configure the rate app prompt. Frequency of showing the prompt can be
set in RATE_APP_PROMPT_FREQUENCY constant. Set frequency to 0 if you don’t want to show
the rate app prompt. Duration of showing the prompt (in milliseconds) can be set
in RATE_APP_PROMPT_DURATION constant.
Tip: It’s recommended to use either the in-app review dialog or the rate app prompt, but
not both at once.
User Agent
You can set your custom user agent string for the webview. You can use this feature to
distinguish if web page is loaded in a standard browser or in the webview. It can be
useful in situations when you want to load a different CSS for the webview, hide
AdSense ads, etc. This logic has to be implemented on your backend. Open
configuration
file mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java and
set value of WEBVIEW_USER_AGENT constant to your own user agent string. Leave the
constant empty if you don’t want to set custom user agent string. Empty means public
static final String WEBVIEW_USER_AGENT = ""; .
Open Links in External Browser
If you click on some link in the webview, web page is opened directly in the webview by
default. Pages can be opened in external browser. If you need this behavior, just open
configuration
file mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java and
set OPEN_LINKS_IN_EXTERNAL_BROWSER = true .
You can also set rules which links will be opened in an external browser and which ones
will be loaded in an internal webview. Open configuration
file mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java and
add/remove rules
in LINKS_OPENED_IN_EXTERNAL_BROWSER or LINKS_OPENED_IN_INTERNAL_WEBVIEW arrays. If a
URL link of a page contains a string from the array, it will be opened in external
browser/internal webview. These rules have higher priority
than OPEN_LINKS_IN_EXTERNAL_BROWSER option. For example "http://www.example.com/?
target=blank" will be opened externally and "http://www.example.com/?target=webview"
will be opened internally.
Download Manager
This feature allows to download files from web into a device. Just click on a download
link and the file will be automatically downloaded into the DOWNLOAD directory. File
URL must have a specific format so the download manager can recognize it as a
downloadable file. You can see progress of downloading in the notification panel.
By the default configuration, URL must ends with a supported extension (zip, pdf, mp3,
avi etc.), e.g. http://www.example.com/path/mediafile.mp3. The default configuration
also supports Google Drive and Dropbox links.
You can modify supported file extensions or expressions in the configuration file. Just
open mobile/src/main/java/com/robotemplates/webviewapp/WebViewAppConfig.java an
d add/remove file types or expressions in DOWNLOAD_FILE_TYPES array as you need.
Entries in this array are regular expressions. If the webview URL matches with the
regular expression, the file will be downloaded via download manager. Keep the array
empty if you don’t want to use the download manager.
Intents in HTML
Application supports Android Intents. You can add a special link to your HTML file and
you will be able to run appropriate external app to perform some action. For example
send an e-mail or call somebody. Following intents are supported (example URI):
E-mail: mailto:[email protected]?subject=Hello
SMS: sms:+0123456789
Splash Screen
There are 30 icons which you can use for navigation drawer menu. If you need to create
an icon for navigation drawer menu, it is recommended to use Android Asset Studio.
Multi-Language Support
Deep Links
The pathPattern attribute specifies a complete path that is matched against the complete
path in the Intent object. It can contain asterisk wildcard * that matches a sequence of 0
to many occurrences of the immediately preceding character. A period followed by an
asterisk .* matches any sequence of 0 to many characters.
Uploading Files
Application supports uploading files from storage or camera. File picker requires a
permission to access storage. Permission request is shown when some file is chose. If
user decides to reject the permission, file upload will not work.
There is a known bug on Android 4.4 so the upload might not work properly on this
version of Android. See official Android Issue Tracker for more info.
Video in HTML
Application supports HTML5 video, YouTube, Vimeo, JW Player etc. in fullscreen mode.
Some antivirus programs may find this app potentially dangerous. One of the reasons
might be using JavaScript. If your app is detected as malicious, you should add it to
antivirus white lists to avoid false positive issues. Usually you have to upload an APK
file. You can report false positive findings here:
Avast
AVG
Avira
Bitdefender
Symantec
Other
This chapter describes how to build an APK/AAB (Android App Bundle) file using Gradle
and prepare the app for publishing. Android Studio uses Gradle for building Android
applications. Publishing an app in APK format is simpler. AAB (Android App Bundle) is a
new format that supports dynamic delivery, but defers APK generation and signing to
Google Play. It requires additional setup of signing keystore in Google Play.
You don’t need to install Gradle on your system, because there is a Gradle Wrapper.
The Wrapper is a batch script on Windows, and a shell script for other operating
systems. When you start a Gradle build via the Wrapper, Gradle will be automatically
downloaded and used to run the build.
Note: You can also create the APK/AAB file via Main menu -> Build -> Generate Signed
Bundle / APK. If you want to do it this way, just choose your keystore, enter your alias,
passwords and generate the file. After the build is finished, the APK/AAB file should be
available in mobile/release directory.
Note: You will also need a “local.properties” file to set the location of the SDK in the
same way that the existing SDK requires, using the “sdk.dir” property. Example of
“local.properties” on Windows: sdk.dir=C:\\adt-bundle-windows\\sdk . Alternatively, you
can set an environment variable called “ANDROID_HOME”. Android Studio will take
care of it.
Versioning
Open the main build script mobile/build.gradle. There are 4 important constants for
defining version code and version name.
VERSION_MAJOR
VERSION_MINOR
VERSION_PATCH
VERSION_BUILD
Keep in mind that versions have to be incremental. See Version Your App in Android
documentation for more info.
Dependencies
AdvancedWebView
Alfonz
Android Jetpack
Firebase
Google Services
OneSignal
VideoEnabledWebView
Changelog
Version 1.0.0
Initial release
Version 1.1.0
AdMob support
Version 1.2.0
Download manager
Version 1.3.0
Material design
Version 1.4.0
Push notifications
Version 2.0.0
Fullscreen video
Better design
Interstitial ads
Runtime permissions
RTL
One config file for everything (Google Analytics, AdMob, Parse, enable/disable
extra features)
Version 2.1.0
Version 2.2.0
Exit confirmation
Version 2.3.1
Version 2.4.0
Firebase Analytics
Deep links
Version 2.5.0
Version 2.6.0
Splash screen
Vector drawables
Version 2.7.0
Version 2.8.0
Robo Templates
License
Codecanyon license
Thank you for Purchasing WebToApp! You are now reading the instructions for the offline
version.
The offline version is exactly the same as the ‘online’ customized version and both have
no connection to our servers and have completely editable independent source-code. The
only difference is that the online version can easily be customized by just entering your
details in our Panel and requires no coding. And that the offline version requires manual
You can customize your template at no extra costs! Just browse to the website:
license to activate!
2 Manual Instructions
Install Android Studio if you haven’t already. More information and video instructions about
https://sherdle.com/help/preparation-2/
Make sure you are at least using Android Studio 3.0, select “Open existing project in Android
Studio” and browse to your template folder. Make sure to select the ‘template’ folder that
After selecting it, make sure to wait for the template to fully be imported. If asked, accept
any downloads for dependencies. Finally, do a full build by going to ‘Build’ > ‘Rebuild
Project’.
]]>.
4. If you would like to use OneSignal push notifications open Strings.xml again and
If you want, you can also translate your app to other languages in Strings.xml
Replace the placeholder color codes for the colors with your own colors (starting with #).
The primary color is your toolbar color. The primaryDark color is your statusbar color.
In the java folder, browse through the com.sherdle.webtoapp package and open Config.java
Analytics
If you’d like to use Analytics, you can enter a value for ANALYTICS_ID
Layout options
them in Config.java. Simply find the setting you’d like to change, like
USE_DRAWER and set the value to either ‘true’ or ‘false’. The line above the setting will
describe what it does. In the case of USER DRAWER, setting it to ‘true’ will show a
URLs to load
Configure the URLs to load and the menu items to show. For this locate and change the
• If you’d like to display a single URL in your app, you can enter one URL in the URL
array, e.g:
• If you’d like to display multiple links in your app, you can enter all your URLs in the
"http://yahoo.com", "http://duckduckgo.com"};
• If you'd like to use icons. Add the images to your project, and then refer to them
You can change your package name by changing the value for 'applicationId' in build.gradle
(in /app).
Now you only have to change your assets (icon and splash screen).
The icon
1. First you will need an app icon, it should be a square .png image.
2. You will need to resize your icon to a 512x512 png image for google play store
3. Rename the 124x124 image to ic_launcher.png (make sure it does not become
4. You will see a folder called 'app', open it and browse to 'res/mipmap-xhdpi/'
5. Now replace the ic_launcher.png file thats inside this folder with your
ic_launcher.png file.
Splash screen
For the best peformance, we recommend the use of a logo with a transparent background
1. Take your logo, preferably a high-quality image for the best performance on tablets
2. Now again open the folder called 'app' inside the template's folder on your desktop
In Android Studio’s menu, go to Build > Generate Signed APK. Next, follow the onscreen
instructions to create a keystore and sign your app. Save the keystore on a safe place,
https://sherdle.com/help/changing-package-name-exporting/#ipt_kb_toc_235_2
3 Finalizing
If you get stuck at one of these steps above, we would like to ask you to use the online
For information on submitting your app to Google Play, you can visit Google’s Help
developer. Next, visit this help page on how to publish your first APK.