I went through Chaquopy docs and found; with Chaquopy, java and python code can be called as user wishes.
I went through example apps and found examples for either calling python from java or running Android code through python and not the other way like calling java function from python.
Is there some example available or some reference for calling java function from python?
It would be better to add such example on Github examples if not already available.
Referred Chaquopy sample app on Github
The API reference is here, and there is a large example here.
If you have a specific problem, please ask another question and explain exactly what you're trying to do.
Related
I am trying to find a way to execute a Python script from my Java code in Android. I did a research on this matter but the only thing I found is, how I can convert python scripts in APK for android (Kivy e.t.c.).
More specifically I have a script which contains a lot of functions.What i want to do is to create an object based on this python script inside my java code and via this object to call my functions.
I can't convert my Python code into Java, because I use various libraries that exists only in python.
Any advice would be helpful and deeply appreciated.
The following a snippet of my Python script. I use the library charm for cryptography.
from charm.core.math.integer import integer,serialize,deserialize
class serializeClass:
def __init__(self)
...
def serialize(self, charm_object):
assert type(charm_object) == integer, "required type is integer, not: ", type(charm_object)
return serialize(charm_object)
def deserialize(self, object):
assert type(object) == bytes, "required type is bytes, not: ", type(object)
return deserialize(object)
One option would be to create a Web Service API to allow your python results be served up over HTTP. Then it's just a matter of Android communicating with an HTTP web service which is simple.
You might find some python to java bridge out there but in my experience these things always have limitations in practice and seem great in theory but don't end up working correctly.
You can use SL4A project which would allow you run your Python code on Android.
Github: https://github.com/damonkohler/sl4a
Tutorials: https://github.com/damonkohler/sl4a/blob/wiki/Tutorials.md
Check out Qpython, could be an easy solution. You can run your python script against the Qpython android python core, or deploy yours.
Checkout this repository: https://github.com/qpython-android/app-call-qpython-api
I have a C/C++ OpenCV source code (which works fine) and I am rewritting it in Java using OpenCV (not JavaCV). I cannot find the correspoding Java class for CvBGCodeBookModel.
I have searched thoroughly the OpenCV-Java site and many results from Google, I have also looked in many files in the OpenCV directory for any clues.
The closest that I have found is class Algorithm
(http://docs.opencv.org/java/2.4.2/org/opencv/core/Algorithm.html &
http://docs.opencv.org/java/org/opencv/core/Algorithm.html )
but I cannot find how to use some methods e.g.:
- cvBGCodeBookUpdate
- cvBGCodeBookClearStale
- cvBGCodeBookDiff
(The program was not initially written by me and I do not fully understand it but I have managed to add some functionality in the C/C++ version. If you need the source code inform me.)
Can anyone help me?
Thanks in advance
I'd like to write a java program that has the ability to input information onto an asp, and then read back the data that is returned from the asp.
Does anyone have any suggestions on how to go about doing this?
Is there an easier/more elegant solution than web scraping?
In order for Java code to work in ASP, it has to be compiled byte-code that can be read by the CLR. A quick Google search of "Java" + ".NET" yielded this: http://www.janetdev.org/
Another thing you could do is just learn C#. If you already know Java, there hardly is a learning curve.
Is it possible to call/run a python script file from Java code on the Android platform using SL4A? Basically I have a full blown Java Android app and I have several Python scripts that scrape some information from various web pages. I would like to be able to call these python scripts with the web page and get the results back. Is this possible? If so, can anyone point me in the direction of an example or two?
Thank you,
Harry
run an SL4A script from my application?
http://code.google.com/p/android-scripting/wiki/FAQ#Can_I_run_an_SL4A_script_from_my_application?
Here you go, a solution on how to make Android applications using SL4A and Python. I have developed a functional Python application following this tutorial so I can vouch for it. I assume you can add the Python code and do your data exchange with JSON.
I personally have never tried to mix these two together, though I will probably try after seeing your post.
Also, if you have any problems/questions, related to starting that example, post them here, I might help.
I want to know if it's possible to execute a javascript function from java. Basically I have a javascript function to which I want to pass a string and then get the output from that function.
If it's possible, how do I accomplish it?
EDIT -
I couldn't find a solution to this, what I did was re-write all the javascript code in Java. But I am guessing, Rhino ported on Android should do the trick. If someone has tried it out, please post a solution.
You probably want to take a look at the ScriptEngine. There are plenty of samples out there on how to use it. Works on anything but Mac where they for some reason selected to include AppleScript instead of JavaScript by default.
Edit: Take a look at this page, there seems to be a Rhino port for Android out there.
Javascript is not natively supported in java. If you need it, you may implement the Rhino javascript engine to do this.
"Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users."