I am developing an Android PhoneGap application, where I need to add my custom camera/gallery views to HTML page - for example some empty DIV in my HTML Page, whose ID, I already have. How to achieve it?
I know how to write Plugins and basic HTML stuff.
is there any way, I can access elements of current HTML page in Cordova Webview?
my requirement is to add my customized camera view to HTML page with whatever dimensions I can.
Although the initial goal of wrapping an existing web app into a native mobile app might look simple enough with Cordova/Phonegap, in practice there a quite a few pitfalls in making sure that the experience is optimal for users and fulfills their expectations for what a native app experience is.
PhoneGap provides a remote building interface at Adobe PhoneGap Build that lets you package and emulate an application for a single platform in the cloud. The PhoneGap Native Packager components have been updated to take full advantage of this feature. When choosing between Cordova and PhoneGap, it's important to note a few things:
What’s interesting about Cordova is that it can be extended using plugins which allow your app to use native device capabilities beyond what is available to pure web apps.
Adobe PhoneGap is a distribution of Apache Cordova and Cordova is an open-source mobile development framework that allows you to use standard web technologies — HTML5, CSS3, and JavaScript for cross-platform mobile development.
Update the answer:
I finally figured out how to do this.
First of all, you need to add your view, such as button, into the Cordova WebView. The Cordova WebView takes care the scroll.
webview.addView(button);
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/android/plugin/google/maps/GoogleMaps.java#L373
If the device orientation is changed, you need to change the size. But in Cordova, you can't not receive the event in java, so you need to listen the event in JavaScript.
window.addEventListener("orientationchange", onMapResize);
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/www/googlemaps-cdv-plugin.js#L1381
And here is the key point. Change the position in HTML to the point in View, you can do this
Math.round(d * webView.getScale());
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/android/plugin/google/maps/GoogleMaps.java#L383
Here is my plugin. I embed a Google Maps Android API v2 into the specified div tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With