Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Python Script from Android Activity

I am collecting some data from my android application. How to run a python script in my android application that uses the collected data as input and generates some output?

like image 316
Prateek Ratnaker Avatar asked Dec 25 '17 11:12

Prateek Ratnaker


1 Answers

Consider Jython, Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. The predecessor to Jython, JPython, is certified as 100% Pure Java.

  1. mbedded scripting - Java programmers can add the Jython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application.
  2. Interactive experimentation - Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.
  3. Rapid application development - Python programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products.

The awesome features of Jython are as follows,

  • Dynamic compilation to Java bytecodes - leads to highest possible performance without sacrificing interactivity.
  • Ability to extend existing Java classes in Jython - allows effective use of abstract classes.

Jython doesn't compile to "pure java", it compiles to java bytecode subsequently to class files. To develop for Android, one compile java bytecode to Dalvik bytecode. To be honest, this path of development is not official , thus you will run into lots of problem with compatibility of course.

like image 93
Remario Avatar answered Sep 18 '22 07:09

Remario