Is it possible to combine cordova and android ndk? - javascript

I want to implement a cordova packaged app in javascript and use c-code for some high performance operations.
Is it possible to write a cordova plugin which then calls into android-ndk using jni?
If yes: How should I set up such a project? Is there anything special I should be aware of before starting?

I have done it successfully on one of my project. Just make a plugin which map your javascript code to your java code. Then your java code will call a C code trough jni.

Related

how to create custom cordova plugin using javascript

Is it possible creating cordova plugin using JavaScript and without Java code.
Plugin preferable for Android.
If yes, please tell me how?
Not possible, you should use Java code to create plugin and integrate it using javascript.
An example for creating cordova plugin in Java and calling it in javascript
http://devgirl.org/2013/07/17/tutorial-how-to-write-a-phonegap-plugin-for-android/

Deleting a file in JavaScript

I am developing a native android app using HTML/CSS/JavaScript. During the App flow, I need to permanently delete certain HTML files (stored locally). Can this be done?
I am a high school teacher trying to develop an educational app. I have basic knowledge of HTML/CSS and near zero knowledge of JavaScript!
modern broswer support javascript file operation but this file system is only in broswer and isolated from local files, refer https://developer.mozilla.org/en/docs/Web/API/File
if u do need delete file on android system, then u need your app provide a bridge to and call from js, run in app, in java code, delete the file
the code might look like
JsBradge.delete(file)
Javascript disigned as a web document script language, so it has many security essentials, such as absolute isolation in browser, which means no write acces to file system.
So, you have two options - first is create your own bridge to java, for example call prompt('your_file_name'), catch it in java and delete your_file_name.
Second - use any of mobile app framework, for example - Cordova.
Sorry, but no easy ways =(

Does IONIC support multi-threading and call jar lib developed in Java

Currently, I'm working on project using Ionic framework and Cordova.
We create some code witch running by java, it will be running on server.
but it will be the same main functionality on mobile devices using Ionic (java script + angularJS ...)
1- Can I get the jar file from the java project and recall those functions in Ionic using JavaAcript, I read many article: some people say it possible and some others say no !
2- About multi-threading, can Ionic support multi-threading or no ? because in my app I have some thread for asynchronisme consuming web services.
Thank you
If you want to access jar lib from cordova project you should use ACE project
You can use Webworker to achieve multi-threading in Javascript.
Hope it helps.

How to integrate objective C or swift programming code into cordova ios app?

I have some objective C code. I need to integrate it into my cordova project.
How can I run that code in my Cordova IOS app?
Your question is a little vague. But to get you pointed in the right direction:
Open your project in finder and navigate to platforms>ios>[project-name]>Classes.
Here you will find AppDelegate and ViewController files. These are written in objective C. AppDelegate handles a lot of the central processes of your app.
If you want to add something specific in ObjectiveC you have to write a plugin. Here's the doc about it : https://cordova.apache.org/docs/en/5.4.0/guide/hybrid/plugins/index.html
Once you've integrated your new plugin into your cordova app, you just have to execute your native callback from the javascript code. It works the same way as an official plugin.
What exactly do you want to add in ObjectiveC, are you sure that you can't do it from the webView ? (I mean in JS and not as native code)

Starting a process via Javascript [Using Rhino JS]

I'm working with a tool that only allows for Javascript as the scriptting language. With the script, I need to launch a process. How would I go about this?
The javascript code is running on the client that will launch the process. The javascript interpeter is RhinoJS.
So my question remains:
1. Is there a way that I can call a specific Java class from Rhino [ProcessBuilder]?
or
2. Is there a way to launch an executable from Javascript? [I've tried the UniversalXPConnect route, but it turns out that the version of Rhino I'm using doesn't really worry about permissions]
That was quick [I found the answer right after I asked]:
var pb = new java.lang.ProcessBuilder("notepad.exe", "c:\test");
pb.start();
Basically RhinoJS has a quirk to allow it to directly access Java functionality. So basically once should just launch the process from there.

Categories

Resources