How should I go about making my kivy application work on a Samsung Galaxy S7? How much of the code do I have to change to make it work? Do I get features of the phone like handling "back" or vibration? Currently my code has two files, a calc.py file which handles all the back-end calculations that are given from main.py which is a KivyApp class which returns my main class.
There are also images that are used in the same folder from main.py
If there is a better place to post this please tell me
Thank you!
You are on the right place to ask this.
First you have to convert your app in a apk using python-for-android, the easiest way is to use buildozer.
You'll probably need to make your code compatible with python2, apparently there is a new buildozer that allow pure python3, but the classic one work on python2.
For the images, if you want to keep them here, it will work, but I recommend that you put them on a "img" repo.
For the vibrations, and other android behaviors, there are 3 way to do this:
pyjnius that let you use every component you want by creating a binding to the android class.
plyer that have already create you a easy binding but don't have all the fonctionnalities.
python-for-android api, that is also really easy.
I recommand you check if you can do what want first with python-for-android or plyer, and if you can't, give a try to pyjnius.
Related
Is there any mobile python IDE that let you get download code from GitHub directly into the app? In fact, IDE would be an overkill - I don't need to code in the app, just need to run code as a quick demo to discuss ideas with people. My code don't launch GUIs, only console outputs.
My phone is Android, but iPhone answers are also welcome. Thanks!
Update:
There are a few suggestions that this may be a duplicate with Is there a way to run Python on Android?. I did read that one before I asked. It is either not the solution I am looking for or I simply misunderstood it - Kivy seems to be a framework to let you develop mobile apps using python, but what I am looking for is something that I can download my github repository and let me run one python file. Or you can say I want a python interpreter on my phone that can execute code (multiple modules/packages) from a online repository.
Anyway, I tried Kivy, and I got a screen like this (not intend to go off topic like the other question did, just trying to show Kivy did not solve my issue):
PyDroid 3 is half way what I want. It is a good mobile IDE to write some simple code in. But I couldn't find a way to download a repository in there. Copy-pasting works for those all-in-one .py files, but not practical for those code living in multiple modules/packages.
I'd suggest installing Termux and using it to run the code just like a linux terminal
I'd like to make an Android app, and I prefer to not have to step out of my comfort zone which is Python. I heard that the Kivy package can make Android apps, but I heard that it likely doesn't have the full Android UI functionality that you could access using Java.
My desired app should have a persistent notification, that's visible even when the screen is locked, and which has 4 buttons on it, which should respond to pressing and holding them. Is that possible with Kivy? Can anyone point me to the functions or classes that I'd use to make this notification and buttons?
I don't know answer for this question, but I have few thoughts you may find useful.
When it comes to calling platform specific API in Kivy it's almost always being done with calling native Java function from Python using pyjnius module. There're not much places where it's actually happens in Kivy: in python-for-android android recipe (source) that provides some basic stuff and plyer project that tries to provide high-level cross-platfrom API to some platform functionalities.
I guess that's all you have now and I didn't see there something that does what you want. I guess only way left is:
Investigate Android API
Write Java solution
Use it from Kivy/Python by pyjnius
But note that if most part of your app is Android API related you probably wouldn't need Kivy at all: you can just avoid third step in this case.
As we all know, when developing an Android app in native Java, we use activities. I was wondering that, in developing Android apps in Python(with Kivy), does Kivy implements activities for the apps in itself or not? because I don't see any activity implementation on the sample codes.
If it doesn't implement activities, Do we lose performance or any functionality in the application compared to coding in native Java?
Simply put, you can use Activities (starting them using pyjnius), but not really define them, at least, it's not usually the way one work with kivy.
Kivy doesn't adjust its way of working for targetted platform, it uses its own systems, and make them work there. For what i know the advantages of separating Activities on android is just a way to make your code more neatly organized, and doesn't imply performance changes. It can allow you to start your app in various ways (from a share, for example) but you can do that with p4a/buildozer too, by dispatching messages about the intent, if you need to. With kivy, you'll organise your code like you would do for any python project, using modules.
Kivy is a great tool for developing Android Apps. The best advantage of using Kivy is that it is cross platform and the same project can be used to publish apps on mutti-platforms.
However , it has some performance related disadvantages(as do most cross-platform tools like unity , cocos etc). If you're developing only for Android , I'd suggest taking a look into development tools which use Java. This will help create a smaller APK file which in turn helps in better user retention.
I guess you are real loyal fan of Python, but I have to tell you about its advantage and disadvantage.
Advantages
Pure python and its almightiness is in your hand.
Relatively simple to deploy with buildozer without any need to dive too deep into the details of particular platform.
You can run your app on desktop also, so there is no need to install some extra emulators/VMs to get it work
Disadvantages
Not that much information in Internet, even on stackoverflow
Pretty messy documentation
No obvious way to test the application
Not obvious machanisms of placing widgets, especially in built in layouts, which causes situations like: you want place widget in the center of it's parent, but kivy places it anywhere but not where you want it to be.
Official examples are quite ugly, so you may get false vision of how your application could look like.
This is just a general question for my information. I know how to create standard Android apps, but I was wondering: How is it possible/how do people enhance Android core functions and dig deeper into the system?
For example:
Let's assume I want to adapt the DownloadManager class, which is used by many apps. So, for example, one can adapt the class so that the download-text, which is displayed in the Notification bar under the download progress, is somehow changed.
Excuse me the following stupid questions, but I have no idea of these advanced topics, that's why I'm asking here ;-)
It is possible to change (for example) the DownloadManager class, so that it has extended functionality which will then be used by 3rd party apps, right?
Can the patched class then be put in the Play Store for other people to download/extend their DownloadManager functionality?
Will people need Root to be able to install such a change?
At most important: How can someone alter an Android API class? I'm really a noob here: I don't know where to get the source-code from, how to replace the standard with the enhanced class, what's needed for that, etc. Is there even a tutorial on advanced topics like this?
Please enlighten me a little bit :-)
is possible to change (for example) the DownloadManager class, so that
it has extended functionality which will then be used by 3rd party
apps.
Yes, of course, Android source code is opened under Apache license, you can modify this source code, and public into the world. For some detail about DownloadManager class and many other class, in Android OS Structure, those class is programmed on upper layer, often totally in Java.
Can the patched class then be put in the Play Store for other people
to download/extend their DownloadManager functionality?
I don't understand your question so much. In Play Store (and another android app store), people upload their application (in funny sentence, upload the source code has been compiled), so how can you upload a source code for user extends their apps ?
You can public your source code to github, or another place that programmers often meet, so they can view your source code, and often give you valuable ideas and comments :)
Will people need Root to be able to install such a change?
if advanced user, they can install new Android OS for their device. But I think, this answer is further than you really need.
Where to get the source-code from, how to replace the standard with the
enhanced class, what's needed for that, etc. Is there even a tutorial
on advanced topics like this?
In Android SDK folder, there is a folder named "Source", you can go there and see many Android source code. You can take that, read, and modify what you want. some part of Android is not here, you should google for this, it easy to find on internet.
But you should remember, when you modified this class or that class, it not belong to Android OS again, you must import this class file to your project as normal class.
So, if you want to modify base Android APIs : those APIs often write all in Java, and you read them and understand carefully, modified some part if you want, and import this class into your project.
And last word, why you should do that :) Because you can extends the class you want, and put some additional features for this class. It's easier and nicer.
Hope this help :)
I am a beginner on android platform, and I want to build a tracerouting app. So these are my queries:
Is it possible to make such an application in Android? if possible then guide me the way that I follow.
Does Android support low-level programming to capture ICMP packets? or do I need to add some kind of JAR (in java) or some other libraries to support this application?
In Java, there are JPCAP and docjar etc kind of libraries that we can import in our IDE or Eclipse so that Java support for making such kind of API's?
I need valuable suggestions.
It's quite late - but someone might see it.
i found this one and it worked for me:
https://github.com/olivierg13/TraceroutePing
The simplest way I can think of is to just check for the traceroute Linux application, execute it, and parse its output.
Android has full networking support, however, Java doesn't expose an interface to alter the IP header. Hence, manually crafting ICMP packages is out of the question (JPCAP is no help here, since it relies on libpcap, which I suppose you won't find on any vanilla installation).
Another possible solution is to use the NDK and create a small library that handles the low-level number crunching. However, I'm not sure if the NDK would allow you to use setsockopt.
This is working pretty well for me, you may have to filter out the string results.
To add this library, you have to download or clone the git repository and implement the folder "library" just as he does in the other module "app" for it to work properly.