I need to call a relatively simple piece of python code (no dependencies) from my java-project for android. I have heard that it is possible to use python via Kivy. Would that be possible?
Kivy cannot be easily integrated in an existing Java app, Kivy (the android part) have already a integrated Java application. Python is the main part, and you can execute Java code from Python using Pyjnius. Or write direct Java code.
You want the inverse, which is not something we are targeting.
I suggest you to check android-python27 project instead.
Related
I have found some ways to using python to build android app.But all of them need to install sl4a and pythonforandroid.
It is so complicated,so is there any way to package sl4a to my android app project,and once I install the apk,I needn't install sl4a any more.
You can use Kivy at following link :
Python for Android
It will can help u have a look to the following topic :
How can I integrate a Python code in the Android Java app?
hope this help you.
You can do this. What it comes down to is packaging the Python interpreter (compiled by the NDK) in your app, and starting it via the standard NDK mechanisms. This is the same thing that e.g. Kivy does, but you'd be adding the code to your own app rather than (like Kivy) using a java bootstrap then letting the Python manage everything else.
One option, which has seen a little discussion/development recently, is to use python-for-android to build all the python components, then copy them into your java project (and add the code to handle it). This is possible, but not currently as easy as it could be, you'd need to look into how it works internally to get the outputs you need.
Another option that is probably easier right now if you don't need compiled code beyond python itself is to directly use the precompiled python binaries of the CrystaX NDK, in which case including the python binaries comes down to only adding them to your Android.mk. You'd still need some C and NDK code to interact with the interpreter, but the process is quite straightforward.
(SL4A has some Android build tools of its own, which you could also use for this, but I don't know what you'd need to do to integrate it as I think SL4A does extra things on top of just having the python interpreter present).
Can I use Python code in Java on App Engine? What I mean is I am using Java to develop my App Engine cloud, but I need to include some Python code in it. How might I do that?
Why?
I need to Generate Dynamic Content using Jinja2. There is no equivalent in Java. So I was hoping to be able to just do it in Python and include it in my Java code.
No you can't run Python code if you are using Java, or vise versa, since App Engine is running in a sandbox and you are not allowed to run anything else other than Java in your case.
I am trying to call up a user defined matlab function(.m file) from java android application which is developed in Eclipse using matlabcontrol.jar.
Actually, It works well when I use it in the java project.
But I wonder is it possible to use it when I develop android application.
The problem is When I use matlabcontrol.jar for java project, it pops up and runs matlab application(like R2009b matlab) automatically, even though I don't want to use it. then run and print result on the matlab console also.
Then, I think, if someone who didn't install matlab application in their computer or smartphone can't use application which is included matlab code.
So, I just want to run matlab code on java program(for android), not using matlab application. Give me option or alternative way to work out please?
Please help.
Thanks.
matlabcontrol just gives you a way to call a running copy of MATLAB from Java. If you have some MATLAB code that you want to run on an Android device, this is not going to work for you, as there is no version of MATLAB that will run on Android.
If you have MATLAB code that you'd like to run as part of an Android application, you have two real choices:
i) Use MATLAB Coder to convert the MATLAB algorithm to C code, that can be compiled, called from Java, and included in your app to run on the device. You'll need to ensure that your MATLAB algorithm falls within the subset of the MATLAB language that is supported by MATLAB Coder, but that usually isn't a big issue. MathWorks have a recorded webinar with a worked example of how to do this (it's Objective C on iPhone rather than Java on Android, but the principles are the same). It's called something like "MATLAB to iPhone made easy", if you want to look it up. Here's the link to it.
ii) Use either MATLAB Builder NE for .NET, or MATLAB Builder JA for Java to deploy your MATLAB algorithm as a web service, and have your Android application call that web service.
PS MATLAB Mobile is not a relevant option here - it is a tool for connecting to a MATLAB session on your machine or in the cloud, and interactively running MATLAB code. It does not give you a way of running MATLAB code on the device itself.
If i created a apk library with monodroid. Can i u use this just in Eclispe(Java) and do my rest code in Java ?
In short: no. A DLL compiled from a Mono for Android class library relies on the Mono runtime in order to run it, which wouldn't be present in a normal Java Android application. It is possible to go in the other direction though, and use Java libraries within a Mono for Android app. Xamarin has documentation of how their architecture available here.
That said, in some cases it is possible to access C# code from Java code when you're in the scope of a Mono for Android application. This question/answer has some good details about that.
I am making a game engine that is targeted for the Android platform using Java and would like to embed a scripting language into it. I have tried Jython, LuaJava, and Groovy but none of the .jars that I include into my project to utilize the languages are working. In result, my game engine fails to run.
I am aware that the Android platform compiles the app into java bytecode and then converts it into Dalvik-compatible .dex format, since Android uses the Dalvik virtual machine. So I am quite sure that, sadly, these scripting languages likely won't work for a java app project on Android.
So my question is, does there exist a scripting language that I can embed into my Java game engine that will work on the Android platform?
Thanks.
Use DeeLang
It should work for what you are using it for or at least what it sounds like you are using it for.
ref URL: http://code.google.com/p/deelang/
Clojure would be an option - that definitely works on Android, I've even got a Clojure REPL app going on my HTC as we speak!
You might also find the answers to Java: Scripting language (macro) to embed into a Java desktop application useful.
LuaJava can be used on Android. Precisely I started with AndroLua which offers a working example.