A complete Python app for Android. How to develop in Python for Android Is it possible to download python for android

In this article, I would like to talk about how to create a complete Python application for Android. No, this is not another manual for creating a script for sl4a , this is a manual for creating a full-fledged application with a UI, the ability to build apk and put it on Android Market. At the same time, I would like to brag about my first application on google.play, this is not hello world, but useful application for photographers, albeit a highly specialized one.

I'll start the story perhaps with the application itself and finish with stories about how it was done.

isortViewer

As a photographer, I have to spend a lot of time sorting and selecting photos. You don’t always want to sit at a work computer when you have a laptop, smartphone or tablet at hand, but copy tens of gigabytes of raw or jpeg files, and then synchronize with a working computer - a dubious pleasure. That is why I created the isortManager and isortViewer programs, which made my job of sorting and selecting photos much easier. Now I can do the selection and sorting of photos lying on the beach couch or bored in a traffic jam :)

Copy-paste description and a couple of screenshots:
isortViewer is a program for photographers that allows you to quickly and easily select and sort thousands of photos (raw or jpg) from photo shoots on your android smartphones and tablets. At the same time, there is no need to copy tens of gigabytes of jpg or raw files to the device. Just use free program isortManager for the computer, which will save everything into one small project file:
1. Download and run isortManager from the official website;
2. Create a project and add photo folders. Supported formats: jpg and raw (cr2, nef, orf, etc.). As a result, you will get a small project file (about 150 MB for several thousand photos, whether it is jpg or raw format);
3. Copy the project file to your android device, open it in isortViewer. You can mark photos "for deletion", as well as set ratings from 1 to 5 stars;
4. After that, copy the project file back and apply the changes in isortManager. In addition to deleting selected photos, you can copy or move marked photos. For example, photos with "5 stars" can be copied to the "masterpieces" folder, and "1 star" can be moved to the "junk" folder.

The app is completely free and available on google.play , however donations are welcome.

Sources are available on the official website!

How it was done

Since python best language programming in the world other than python, I know nothing, it was decided to write an application in python.

isortManager

There were no problems with isortManager for PC, creating a GUI assembly for windows has long been tested and it works very simply: using dcraw, it tears out jpg previews from raw files, resizes them using PIL and puts them into one file with a fairly simple structure. I invented my own container for storing photos and metadata (the full path to the photo, the “for deletion” mark and the rating mark), since, for example, zip or tar format cannot change one file in the archive (metadata), I require repacking all files. The files are simply written one after the other in a row and in the metadata block (the usual repr of the Python dictionary) at the end the offset of the beginning of the files is stored, plus the size of the metadata block is written at the end of the file. The GUI is written in Tkinter (I love it for the speed of writing and for the small size of the final assembly), here is the actual screenshot:

And yes, all this works on linux, and even faster than on windows)

isortviewer for android

In total, I found two ways to make a python application work as a full-fledged android application, these are pygame for android and the kivy project.
Pygame is more low-level, all the UI would have to be drawn by hand, which would take a lot of time, so the kivy framework was chosen. So:

This is a wonderful framework for writing an application for windows, linux, MacOS, android and iOS. Multi-touch is supported, the UI is drawn through OpenGL, which means that hardware acceleration should work. You can see the widgets in action by installing the Kivy Showcase demo app. It is possible to use some platform-specific functions, such as vibration or accelerometer, using the android module.

hello world looks like this:

Import kivy kivy.require("1.0.6") # replace with your current kivy version ! from kivy.app import App from kivy.uix.button import Button class MyApp(App): def build(self): return Button(text="Hello World") if __name__ == "__main__": MyApp().run( )

Moreover, this code will work on all declared platforms. There is no need to test the application in the emulator. It is enough to run the script in your favorite IDE and see the result on the computer screen, without delays for compilation, launching the emulator, etc. If you still want to see how it will look directly on the device, just install Kivy Launcher, copy the project files to the card memory and run. You can debug with adb logcat.
If you are using the android library, which is not on the PC, but you want to run the application not only on android, use this construction:
try: import android except ImportError: android=None ... if android: android.vibrate(0.05)

Building apk is quite simple and is described on this page. After building the release, it is enough to sign your application (I used this manual) and put it on google play.

Pros of kivy:

  • Rapid development for various platforms, with little to no code modification.
  • Wide variety of widgets available
  • High speed. All resource-intensive is moved to C modules. The python interpreter itself on android works natively.
  • The framework includes many tools, such as animation, caching, etc.
  • upd: Access to the camera, clipboard, microphone. You can write your own video player in just 20 lines.

Cons of kivy:

  • Big size apk file. A project with 300 kb of resources (scripts, graphics) is collected in 7 mb apk. Although, I think there is an opportunity to optimize it somehow.
  • Impossibility (yet), to restore work after minimization - the application closes

In my next article, I will talk in more detail about the process of writing an application from scratch, chewing on each line of code.

I would like to immediately stop the holivars on the topic "only java for android, python is not needed." I think it doesn't matter what technologies are "under the hood", the main thing is that the application is of high quality.
The scope of kivy can be huge. Now I have several applications written to order, where python with the kivy framework has shown itself to be good. For example, in exactly one hour, an application was written for the network service centers. The application works in kiosk mode and is installed on cheap Chinese tablets that hang in the lobby. The customer dials the order number, then wifi tablet connects to the server and reports the status of the order.

Tags: Add tags

17 11.2017

Development of development technologies software does not stand still and every day there are new languages ​​and libraries that help make the development process as fast and efficient as possible. Many developers who choose new language programming to learn, especially for writing applications for the Android operating system, stop at Python Android. In this article, we'll take a look at Python as an Android programming language, discuss app development, installing apps on Android, and many other topics that will be of interest to many beginner Python developers.

From this article you will learn:

Welcome to the kip-world blog pages! With you, as always, I, Gridin Semyon, and today we will tell you about programming in Python for Android. We will cover topics such as installing Python, developing and running applications.

Python apps for Android OS

On the this moment, Python is one of the favorite development languages ​​for novice programmers, especially for people interested in developing software for devices running the Android operating system.

Python for android allows you to create simple applications with a minimum of costs. Moreover, having once understood the principle of development in python for android, the developer will no longer need to delve into the details and nuances of writing a program. Moreover, the Android API is well organized and easy to use.

First of all, we need the right development environment. Decide on the current Android version, given that the operating system is backwards compatible.

In other words, applications developed for version 6.0.2 will work on 5.0.1, but often applications developed for older versions of the OS are not supported by newer versions.

Install SL4A, a convenient development environment and start creating in accordance with the guidelines available on the official website dedicated to the operating system.

It is also worth considering that applications can be developed and installed not only on the android operating system, but also on devices running other operating systems: MAC OS, Windows and Linux. This feature expands the horizons of development, allowing you to use the environment that is convenient at the moment.

Installing python on android

The next question is how exactly python for android gets the ability to run our applications on the device. Developing in python for android with the python for android tool simplifies your work in that this tool creates a distribution kit on your device - a special encrypted folder that contains all the data necessary for the project.

You can install this tool directly from the official android website, after which you can easily run the necessary applications on your phone.

For convenient development and, in fact, development directly from the device, we need . Quality programming in python for android requires the installation of the correct interpreter.

One of the most popular is QPython, which can be started immediately after installation. Moreover, the interpreter allows you to write and run written applications directly from the developer's interface.

If you want to run the interpreter without using the application, you will have to write a small script that will take no more than 30 minutes to create. With the help of such a script, we can launch the application directly from the terminal, or with the help of an automated script.

Such a script can be written in advance and placed on a convenient source (including a memory card) and run at a convenient time for the user. There are many interpreters, so it will take some time to find your own.

The QPython interpreter allows you to run applications, including python games for android, directly on the selected device. This interpreter also contains a console, a conditional development environment, an SL4A library, which is simply necessary when creating scripts for scripts.

The advantages of QPython are:

  1. Support for interfaces such as GPS, mobile network and bluetooth.
  2. The ability to execute the script directly on the device.
  3. Support for python packages for android, which are developed in advance and once.
  4. Support for many of the most popular libraries that make development as correct, fast and comfortable as possible.
  5. Possibility of programming directly on the device.
  6. The ability to run the written code on different devices - from mobile to full-fledged success.

The convenience of working with Python lies in the availability of dozens of high-quality official manuals that allow you to create great applications yourself and almost from scratch.

This makes it possible not only to learn independent programming, but also to get a full-fledged program for a mobile device.

As you can see, you don't need to learn a language as complex as Java in order to write decent Android apps.

You can also choose a simpler language that will not only be easier to learn and use, but will also be more “Elastic” and applicable to life as the conditions in which we need to participate change.

We hope that our article was useful and informative for the user. Tell us what programming languages ​​do you use? How often do you update your knowledge or learn new programming languages?

Leave your comments under the post, share the post with your friends and ask questions, which I will be happy to answer.

Sincerely, Gridin Semyon

Under this name in Google Play you can find three good apps(In general, there are more of them, but you should not even waste time installing others). The simplest of these is the Udemy Python 2.x course packaged by the SoloLearn team into an Android app format. It contains lessons that are divided into two levels: basic and advanced. Inside - a brief reference material in text or PDF format. For individual lessons there are examples of working code. Does not require a network connection.

Learn Python

This application offers users to learn the third version of the language and has much more functionality. The main screen is reserved for displaying the individual stages of the course and personal results. In the menu you can find a section for free creativity in Python, download courses for other programming languages, and also study help information. The application has an interesting feature: everyone who completes the course and solves problems gets points. Their total number can be found on a separate tab. So there is an additional game component that can motivate someone to study more carefully. At the end of the course, you can get a certificate of mastering a programming language.

Learn Python Programming

The third application, developed by Phoenix App Labs, has the widest functionality and the most colorful interface. There are not only lessons for beginners and those who have already studied the language, but also the ability to download finished projects in Python directly from the application, detailed statistics of the studied, separate tab for easy access to own programs and an element of social competition in the form of an online coding championship with a leader board. In case of successful completion of the course, each user receives a certificate.

QPython

A complete Python programming environment for Android devices. Includes a Python interpreter, a console, an editor, and an SL4A library that allows you to create and run scripts directly on your gadget (work with smartphones and tablets is supported, since there are libraries for working network interfaces, GPS). So in this application you can code and create full-fledged projects. If you have a good Python tutorial and ready-made projects at hand, QPython will be more than justified, despite the lack of built-in learning functions.

Python Documentation

Stylish application with Python 3.5 documentation on English language. Able to work offline. There is a section with examples of ready-made code, although the main purpose of the program is detailed help for those who have already mastered basic principles language. Has a very convenient search and easy navigation.

Quiz&Learn Python

This app is designed to practice your existing Python 2.7 programming skills in the form of short questions covering both the basics of Python programming and very specific and unexpected ways of writing code. Quiz&Learn Python keeps statistics based on the speed of your answers. Depending on the progress, the questions may become more difficult. They can be skipped (this affects progress: the program asks simpler questions). In addition, using the built-in debugger, you can write a question and check the answer in practice.

Python Challenge

Another application for those who have already learned the basics of programming and want to expand their knowledge. The Python Challenge is a question-and-answer game. Each round has 20 questions containing executable code. They are given a certain amount of time to answer. There is a section containing the same questions, grouped by topic, which can be answered without time limits.

Python Exercises

Handy application with text lessons and examples. Python Exercises has a very detailed rubrication, full coverage of basic topics, and a simple interface. Unfortunately, there is no way to write code here, so either another program or a second device is required.

- as it is not difficult to guess from the name of the application, in it you can get the simplest possible learning of the Python programming language. So if you have long wanted to start learning this language, then you should start with this wonderful program. After all, it is fully translated into Russian and will help you with tips. Usually such applications are not translated into Russian, which causes a number of problems.

In this case, everything is convenient and excellent. A lot of lessons and tests will allow you to get the most efficiency in learning. That is why many users began to respond very positively about the application. Never before has it been so easy and convenient for you to start learning a programming language. The developers have tried to make everything as convenient and clear as possible.


This can come in handy in a variety of situations. That is why a huge number of users feel free to install the application on their mobile devices and they are very happy with it. After all, you no longer have to rack your brains in search of a quality program that could be. The program will really help you start learning languages ​​and understand what is happening in the code.

In the process of learning a language, we usually use a PC to work with relevant applications, environments, programs, read books, use mass online courses. Now, when smartphones are with us always and everywhere, it is a sin not to take advantage of their opportunities to learn programming knowledge or improve it.

In the process of learning a programming language, in particular Python, I believe that you need to immerse yourself in it completely. Slogan: "Not a day without a code!" I supplement, well, if not coding, then at least read about it. In order not to get out of the rhythm in conditions when you need to do a lot in life, but there is no time, but I would like to learn Python, mobile applications will help you not to waste time in transport, while waiting, etc. I offer a list of applications from Google Play to learn Python on Android devices that will help you not only gain knowledge, but also test your level in Python. Three of the following applications I definitely recommend to students when learning Python: Learn Python, Quiz&Learn Python and Python Challenge. Well, now more.
1. Learn Python Rating 4.8 on 10/20/2015
One of the best, nice application: the interface immediately pleased. Contains short lessons and quizzes that control the process of learning Python. There is an element of excitement - score points for passing classes and tests. At the end of the course you can get a certificate. The application covers the following topics: Python basics, data types, control structures, functions and modules, working with files, functional programming, object-oriented programming, regular expressions.


2. QPython - Python for Android Rating 4.4 on 10/19/2015
QPython is a script that runs Python on Android devices, allows you to run scripts and projects. QPython contains a Python interpreter, console, editor, and SL4A library (it does not always allow the creation and execution of scripts written in various scripting languages ​​directly on Android devices. SL4A is intended for developers and is still in alpha testing - en.wikipedia .org/wiki/SL4A) for Android. As such, the app offers a developer kit that makes it easy to create Python projects and scripts on Android devices. Main characteristics
  • support Python programming on Android, including web applications, games and SL4A programming, etc.
  • executing Python scripts/projects on Android devices
  • can execute python code & files with QRCode
  • QEdit makes it easy to create/edit Python scripts/projects
  • includes many useful Python libraries
  • pip support (the package management system is used to install and manage software packages written in Python en.wikipedia.org/wiki/Pip_ (package_manager))
  • support SL4A programming to access Android features: network, Bluetooth, GPS, etc.

There is also a QPython3 application which, unlike QPython, has python3 support.
3.Python Documentation Rating 4.4 on 10/19/2015
Convenient and stylish application with Python 3.5 documentation in English, completely offline. Has improved search, easy navigation, mobile reading format, user-friendly interface. The content of the documentation includes the following sections:

  • What's New in Python?
  • Python Tutorial
  • Python reference library
  • Python language reference
  • Python setup and usage
  • Python HOWTOs
  • Extensions and attachments
  • Python/C API
  • Installing Python Modules
  • Uninstalling Python Modules


4. Quiz&Learn Python Rating 4.1 on 10/19/2015
Quiz&Learn Python application for testing and improving knowledge and concepts of Python (version 2.7). Questions range from the basics of Python programming to very specific, perhaps unexpected ways to write code. Depending on the progress, the questions may become more complicated. The faster you answer, the more points you get. You can delete two incorrect answers, skip a question, stop a timer, or debug your code. Developer site mobileicecube.com/quiz-learn-python.


5.Python interview questions Rating 4.0 as of 10/20/2015
An interesting application. Helps to test knowledge of the Python language in the form of an interview.


6.Python Challenge Rating 3.9 on 10/19/2015
This application is an English test for users who would like to learn and test their knowledge of Python programming. The application has two main modes: Challenge Mode and Practice Mode. Challenge Mode consists of 20 questions. Points are awarded based on the time required to resolve each issue. The test ends when the user selects an incorrect answer or completes all 20 questions. In Practice Mode, questions are sorted into different topics. The user can choose them. There are 10 questions. The user can continue the test even if he does not give the correct answer. All questions and answers will be shown at the end of the workout.


7.Python Guide Rating 3.9 on 10/19/2015
This appendix is ​​a quick start guide for Python. The guide will be especially helpful for beginners who want to get familiar with the rules of Python syntax. The guide covers the basics of Python programming so that users will have enough knowledge to create some simple and productive application. The manual consists of the following topics: variables, conditions, functions, loops, lists, strings, dictionaries. Small list. I would like more.


8. Python Programming in a day Rating 3.0 as of 10/20/2015
The developers of the app advise us to skip the long, complicated books on Phyton. In order to learn how to program in Phyton 3.0 faster, they offer a short and concise application that will teach you everything you need to program in Phyton. This book is written for people who have no knowledge of programming or are beginners. It focuses on the most important concepts with examples.


9. Learn Python & Python Django Rating 3.0 as of 10/20/2015
This application finally differs from the previous ones in that it affects not only Python itself, but also Django. This is essentially an English tutorial on Python and Django on the Udemy platform. Its content includes such topics as: Python and Hello World, overview and history of Python, functions, classes, databases, modules and packages, JSON, Django installation, admin interface, Django templating language, and more... There are 18 lectures in the appendix, more than 4 x hours of high-quality content, community, video and audio lectures, presentations, articles, courses can be saved to view in offline.


10. Python Tutorial Rating 4.0 as of 10/20/2015
A collection of tutorials on Python 2 and 3. Talks about the history and philosophy of Python, how to install Python, work with numbers and strings in Python, data types and variables, functions, etc ... I did not like that it was a little out of tune with the possibilities mobile phones- the fonts are small in some places. The name in Russian inspired me that the tutorial could be in Russian - but no! In general, I did not find applications in Russian.


You can also name applications such as:
  • Dive Into Python 3 - book by Mark Pilgrim, rated 3.8, has problems with interface stretching.
  • Python For Android - Python IDE, rated 3.3 due to intrusive ads
  • Python Tutorial - Python 2.6 programming tutorial, rating 3.8
  • Python Programming Tutorial - Python 2.7 tutorial, rating 3.6