Use as a WebView Component
When you use the Embedded Editor in an Android or iOS application, you can either launch the mobile device browser to load the reporting page or use the Android component WebView
or iOS component WKVebView
. In either case, construct the URL passed to the mobile device browser or WebView/WKVebView
based on how you want the user to interact with the Embedded Editor. You need to add the relevant app_id
and app_code
credentials to the URL in order to use the service.
startBrowser()
in MainActivity
as follows: String feedbackUrl = "https://mapfeedback.here.com/";
// use a view intent on the URL to open the default browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(feedbackUrl));
startActivity(browserIntent);
WebView
. If you are using an iOS application, create the functional equivalent for iOS. - In the application
AndroidManifest.xml
file, enable the correct permissions as follows:<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- Configure the
WebView
to enable JavaScript and Geolocation capabilities as follows:// make sure we're properly set up to do JavaScript and Geolocation WebSettings webSettings = myWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setGeolocationEnabled(true); webSettings.setGeolocationDatabasePath( this.getFilesDir().getPath()); //cache the geolocation data
- Configure the
WebView
to handle all URLs in the application as follows:// We want the WebView to take care of all URLs and not open a browser myWebView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { return (false); } });
The URL passed to
WebView
should be constructed to create the correct user experience. - Set up the Back button as follows:
// we want the back button to work properly inside the widget @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) { // unless we have submitted properly, 'back' takes us back a page in the WebView if(!myWebView.getUrl().contains("#/submit")) { myWebView.goBack(); return true; } } return super.onKeyDown(keyCode, event); }
- Implement logic to completely close the Activity when the URL contains a "#/submit" as this is when the user has submitted a feedback request.