English 中文(简体)
安德列斯和杰里
原标题:Android and Python

Can I port existing python scripts on android using SL4A or ASE ? What I specifically want to do is to create an android application with normal UI elements and run the python scripts from the application itself, get the output and display it. Is this possible ?

最佳回答

我本人认为你含蓄地要求提出三个要点:

Compatibility Desktop/Mobile

第一个问题是电话的假装图书馆与贵计算机的假装图书馆之间的兼容性。 如果你不使用第三方图书馆,确保列入extra 由sl4a提供的餐厅一般应为ok。

Packaging

The second point is about how to package a Python app for android. It can easily be done with a wrapper as well described on the sl4a website. In fact they distribute a copy of a chapter of a book about SL4A that describes how to do that. So that is possible, but bear in mind that the user will be required to install python if he hasn t done so already (this is a sort of alert at the launch of the app)

UI

The third thing that you should have in mind is that you are not a 100% free concerning the widget/layout you can use with sl4a. Namely you can t really do whatever you would be able to do in Java or Scala. So you might have to consider altering your UI and do a webview instead (that can communicate back and forth with the python) with a framework to obtain a "mobile look and feel"

Hope this helps.

问题回答

我认为,你想要做的是独立地编造一个文件,其中包括假语解释和你的文字。

I don t know if this can be done in Android. The only whay I know is running your script from Android Scripting Environment.

如果网络接口是正常的,则查询http://groups.google.com/group/android-scripting/browse_thread/thread/f862549d2686e2/f828f916411d7a95”rel=“nofollow”http://groups.google.com/group/android-scripting/browse_thread/thread/f862549d2686e2/f828f916411d7a<95/a>。 您可以使用Adhur、网络电文、超文本5和 Java本

我也存在同样的问题,最后通过在 Java写一个小的单州级班,从SL4A安装的SL4A安装中,用java.lang制作的分工艺中操作Adal-4-Android binary。 ProcessBuilder。 因此,我根本不使用SL4A机制(触发器、召唤等),只是借款。

This seems cleaner than trying to start and connect to a Python process through SL4A.

This is Python 2.7.1, cross-compiling extensions from Mac OS X Snow Leopard. My Python modules are doing only text input and output, accepting socket connections, etc. No interaction with the Android API. It all works fine: writing a Java stream to Python input and reading a Java stream to get Python output. C extensions are build using the P4A instructions . (Android could not find .so dynalibs until I added

[build_ext]
inplace=1

to setup.cfg during the build. I think this is because setup install is never invoked on the Android. I m just pushing with adb.

All the activity lifecycle states seem to be working, but I can t yet determine whether the sub-process is automatically suspended while the main process is in the stopped state.

如果有兴趣的话,我可以在几个星期内张贴法典。 (休假)

我的包装计划是将ZIP的档案存放在/资产中,并在首个Create时备注。 我没有这样做,但我并不期望有任何问题。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签