Android - Web connect back to native code by JavaScript? - javascript

I'm trying to develop a hybrid APP that will implement in webview.
In this APP, I want all user interfaces load from server and functions (such as wifi scanning) work by native code.
Is it possible if I click the icon in the UI and it will send me back to implement native code by JavaScript?
(I have tried PhoneGap, but there doesn't have the plugin can support the function I need.)

Related

cordova - call javascript from android background service cordova plugin

Currently, I am developing an Ionic2 app that should have an ability to connect automatically to paired bluetooth devices in range while beeing closed/killed in order to collect specific data.
Using this plugin https://github.com/Red-Folder/bgs-core, I am creating a background service for android.
Since most of the main app logic written in JS, I would like to know whether it is possible to call functionality written in JavaScript from cordova plugin (in case of Android from Java) while the application is closed. If yes, how can I do it?
As an alternative, are there other cordova plugins that support background execution while an app is killed?
I have found similar questions, however, none of them contains a sufficient solution:
run javascript in background service on android phonegap
How to run cordova plugin in Android background service?

JavaScript or HTML launching a new browser from hybrid app

So, I'm working on an app which is a web based app. The apps code base is mostly written in JavaScript and HTML. The app is also available on a native app which basically only contains a WebView displaying the HTML and JavaScript code.
My problem is that when a user is on the Android native version and launching an external link, it opens perfectly in the Android WebView but there is some cases where the launched page not is scrollable and other strange stuff.
So to solve this issue I need the native app to launch the in-build browser in the Android phone. Basically, the exact same effect that startActivity(new Intent(ACTION.VIEW,URI)) has.
The thing is that I can't modify the Android version though all the logic is written within the web app..
My question is:
Is there any way to simulate:
startActivity(new Intent(ACTION.VIEW,URI))
in JavaScript to get out of the native app and launch the browser instead?

How to send real-time data to a page loaded in UIWebView from iOS app

I've built a web page that shows a map along with geo-tagged images. I would like to also show some real-time sensor data, for example noise levels.
I can put the page in a UIWebView in iOS and I can access the sensors I need from a native app (built in Xamarin if that's relevant).
I can obviously build web services on my server and send the sensory data from the native app, then use ajax to get the data to the web page. While there are good reasons to do this I would still like my app to continue working (albeit with decreased functionality) while it's not connected to the internet - I need to be able to pass the sensory data (json) from the native app to the web page without reloading the web view itself.
Q: Is there a way to continuously pass data from the native app to the page inside the UIWebView?
I have implemented the bridge for Xamarin (and WP8) here: https://github.com/sami1971/SimplyMobile/tree/master/Core/SimplyMobile.Web
Take a look at the WebHybrid class (it has partial class implementation for Android, iOS & WP8 in addition to the core partial class).
Here is a small sample application: https://github.com/sami1971/SimplyMobile/tree/master/iOS/Tests/WebClientTests
Take a look at this Xamarin Component
Allows for bidirectional communication with the UIWebView in
Monotouch.
http://components.xamarin.com/view/jsbridge

HTML5 Application (server or client side) using phonegap

I need to develop an HTML5 mobile business application using PhoneGap. After finishing my application I want to make it a native app.
Can anyone tell me What is the best way to do it
Develop an application using HTML5 and Javascript, call web services from Javascript and embed it in a native app using PhoneGap
Develop an application using HTML5, Javascript and PHP. (server side). use PHP to call web services. use PhoneGap to call server urls.
1st one seems more native and fast. 2nd one seems more flexible and secure, but I need an additional server for that.
so what is the best solution?
Although I agree this is too wide a question, I would go with #1 because certainly in the case of Apple and iOS I am pretty sure you would not be able to get an app past Apple's gatekeepers if it loaded remote code (Javascript, etc).
Calling out to a web service for remote data via AJAX, etc is fine however.

Create a app by using java script on Android for multiple devices

I have an HTML app which calls some functions from JavaScript files, and the JS files make some AJAX queries and get JSON objects in response.
I have to make a similar app on Android which can be run on multiple devices (Android), by using the same JS files. In other words, I have a JavaScript API, and I have to use this API to make the app on Android.
I have some queries:
Would it be feasible by using WebView (considering it's a big app not a small app)?
Should I use PhoneGap?
Please let me know how could I do this and welcome to some more suggestions.
Answers :
Yes , Using Webview you can build application using HTML + Java Script
Its depend upon you applications functionality and usage of your application. If you want to make your app Cross Platform like (Android , IOS ) You should try out Phonegap.

Categories