Running python programs on android - android

First of all I apologize that I am not a programmer and my IT knowledge is limited.
I have written a very basic python program which runs on windows.
I just want to run it on my android phone.
I checked with Qpython app for android and I could not figure out what to do with that.
Please let me know how I can run this program on my android phone.
Please describe the solution keeping in mind that I don't understand much of the IT jargon.

Run python program in android with Qpython:
Create program and run it:
Go to Editor.
Write Your Script.
Tap Save icon. ('4th icon' at bottom)
Tap Run. ('Arrow icon' in middle at bottom)
Script will run and output/errors will be shown in logfile in notification bar.
Run existing script:
Tap on big button with python logo in center of screen.
Tap run local script.
Tap on script you want to run.
http://wiki.qpython.org/doc/how-to-start/
edit: There is another app from same developers called Qpython3 in which you can run python3 applications including scripts and projects.In Qpython3 after running script it will take you to console for output instead of showing logfile in notification bar.

It is same as Windows/Linux. You just have to be confident before trying something new. IMHO no one is professional at first try.
Please see video and let me know if you need further help.
https://www.youtube.com/watch?v=UqlTErvbRdE
For long and deep understanding:
https://www.youtube.com/watch?v=So2weWysyZc

I you know python 2(version).This will help.
http://code.google.com/p/android-scripting (the home of the SL4A project.)
This is by-far the best way you can run your Python app on android

Related

What is your dev flow for React Native Android?

For the last few weeks I've been developing an app for Android using React Native, and overall the experience is pretty good, however I feel like I might be missing something. Does anyone have any pointers?
My flow is
Start Android Studio
Wait for build/sync
Run app on physical device or AVD
See the expected red screen
Start the Metro server
Now the app is running
Run pidcat com.myapp to see device logs
Make JS changes via VSCode
Hit reload in Flipper (no hot-reloading?)
Re-navigate to the screen I'm working on
So far it's all good other than the lack of hot-reloading.
However whenever I made a change to some Java code, I need to hit Rebuild in Android Studio, and this takes quite some time usually.
Is this all normal? Perhaps I'm missing something.
Thanks in advance
You don't have to start Android studio.
If using Flipper, start Flipper first.
Start metro server in one terminal
run react-native run-android in another terminal.
To reload type r in the terminal with metro server.
Changes to JS side should automatically reflect in the device. ( https://reactnative.dev/docs/fast-refresh )
With react-native you shouldn't be making big changes to the native side of the codes. If reloading doesn't reflect the changes to the native side. Then close the metro server and build again.

Ensure that the Eclipse LogCat displays items relevant to my application

When I run my Android application in Eclipse on my machine, it automatically sets up a LogCat filter for my application, and only shows lines that are relevant to it.
However, running the same application on another PC (which happens to have Eclipse 'Mars') running on it, it just has one filter saying 'All messages (no filters)'.
Is there a setting somewhere to turn this on?
And incidentally, I know that I can set up a filter manually, but I liked the functionality that I had before, so I just want to turn that back on.
Regardless of what IDE you use I would recommend you take a look at pidcat.
From the repo:
Colored logcat script which only shows log entries for a specific application package.
You do need a bash terminal.
I will also recommend you move your project over to Android Studio.

How do i install crosswalk for android on windows

crosswalk host setup link
crosswalk is the new way to make html/js based android apps that give somewhat good performance, at least that is what I have heard. To try it out I have to install it. But due it being so unknown, NO tag here for it, there are no indepth guides of what to do and especially what to do if something goes wrong. And there are tons of little steps needed, so workflow isn't optimized either. Since all technical sites say ask question here if have any problems I am going to.
Whenever I install crosswalk start step "INSTALLING THE DEVELOPMENT TOOLS"...
I do this:
Install utilities (Check Have Git bash)
Install python (Already have it)
Install Java Dev Kit (Done)
Install Ant (never ending command line with beeping??)
So you can see I am stuck here...Ant step. The cli opens with tons encrypted text after this command:
curl http://www.apache.org/dist/ant/binaries/apache-ant-1.9.3-bin.zip \-o ant.zip
The thing just keeps going on... So what should I do? is it how it's supposed to be?
Thanks in advance for any assistance. Or if you think I should just leave crosswalk forever or for now than let me know why you think that.
The solution is to NOT use git Bash or command line to download. Instead just take the link and download it which will take few second without making anything unresponsive. Compared to cli way where it'd just keep beeping. Once it's downloaded. Just move it to your user folder and extract it either with whatever program you have like winrar or cli.

GUI-less programming for Android as if it were an ordinary Linux system

I need to do some menial batch tasks on my phone, and I don't want to jump through all the hoops of making an "app" with a GUI and all that just to do them (the tasks are of the type you'd hack together in BASH in five minutes on a sane system). I can't seem to find any place on the net that explains how to simply make an ordinary program (in any language, but Java is OK if that eases interaction with Android) with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process. No need for an APK package, no need for a GUI, no nothing. This should be the simplest thing in the world, but every example out there seems to be first and foremost concerned with making a GUI and working with Eclipse and the SDK instead of doing the basics first.
Any tips?
(I know this is probably borderline SuperUser, but then again, there's a programming question at the bottom: How do you make an ordinary (Java) program that can be run from the terminal on an Android phone and still use the API?)
Here : Running a shell script on android device using adb
and : https://play.google.com/store/apps/details?id=stericson.busybox&hl=en
and : http://forum.xda-developers.com/showthread.php?t=537827
and : http://strawp.net/archive/recipe-for-a-decent-bash-shell-in-android/
and : http://digitaldumptruck.jotabout.com/?p=938
I can't seem to find any place on the net that explains how to simply make an ordinary program (in any language, but Java is OK if that eases interaction with Android) with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process.
That's because it's not especially important to the bulk of Android users or developers.
How do you make an ordinary (Java) program that can be run from the terminal on an Android phone and still use the API?
You are welcome to use the Scripting Layer for Android to write some scripts, but you have limited access to the Android SDK, and they cannot "simply be run by SSHing into the phone". This is supported by the SL4A team.
You are welcome to experiment with the dalvikvm command, though off the top of my head I do not recall whether or not it is available on production devices, and I do not know if it can "simply be run by SSHing into the phone". And, bear in mind that using this is completely unsupported.
You are welcome to write your own C/C++ code for ARM (or whatever CPU architecture your device runs). This "simply be run by SSHing into the phone" but has no access to the Android SDK.
I still cannot believe that that kind of stuff isn't on the first page of every Android development introduction out there.
There are over 200 million users of Android devices. What percentage of those users do you think want to
"make an ordinary program... with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process"? 0.01%? 0.001%? My money is on 0.0001%.
The "first page of every Android development introduction out there" should be focused on stuff that matters to closer to 100% of the user base. You, of course, are welcome to build up your own site focused on this sort of thing, to cater to those users who are interested in creating these sorts of programs.
From http://git-annex.branchable.com/design/assistant/blog/day_184__just_wanna_run_something/:
While I already have Android "hello world" executables to try, I have
not yet been able to run them. Can't seem to find a directory I can
write to on the Asus Transformer, with a filesystem that supports the
+x bit. Do you really have to root Android just to run simple binaries? I'm crying inside.
It seems that the blessed Android NDK way would involve making a Java
app, that pulls in a shared library that contains the native code. For
haskell, the library will need to contain a C shim that, probably,
calls an entry point to the Haskell runtime system. Once running, it
can use the FFI to communicate back to the Java side, probably. The
good news is that CJ van den Berg, who already saved my bacon once by
developing ghc-android, tells me he's hard at work on that very thing.
and some specific advices in the comments below:
See http://kevinboone.net/android_nonroot.html for info on where in
the android filesystem you have write, exec ability.
Basically you have these abilities in /data/local from adb shell (and
in debuggable app's folders using run-as with adb shell), and in
/data/data// for each app (for example the terminal emulator's
data dir when using the terminal emulator).
...
http://git-annex.branchable.com/design/assistant/blog/day_185__android_liftoff/:
Thanks to hhm, who pointed me at KBOX, I have verified that I can
build haskell programs that work on Android.
http://kevinboone.net/kbox.html:
KBOX [...] gives you the terminal emulator, a
decent set of Linux utilities (supplied by busybox), ssh and rsync
clients and servers, and a few other things. In addition, there are a
number of add-on packages for expanded functionality.
Well, it's just about running an executable on Android, and not about writing an executable that would access Android API...
I can't seem to find any place on the net that explains how to simply make an ordinary program [...] with access to the Android API that can simply be run by SSHing into the phone and running it as a normal process.
An answer, translated from a note by vitus-wagner:
Termux is an advanced terminal emulator plus lots of Unix-like software with command-line interface (in packages managed by APT). Actually, not only CLI (command-line), but also GUI as well (though the GUI software not tried yet).
Unlike the way of the various popular "linux deploy" (which make something like a container, at least a chroot, with things installed into directories according to the traditional filesystem hierarchy), Termux seems to aim at integrating into the host system. For this purpose, it has a plugin, Termux:api which is able to do a lot of interaction with the system: open a file in a native Android app, send an sms, take a picture with the camera, or even say something by means of the system TTS engine.
There are many more addons -- see wiki.
(A side note. An integration like that could be expected--if not from MSYS--from GnuWin32, but there is nothing close to Termux under Windows w.r.t. the degree of integration.
However, for some strange reason, people are asking much more about how to make it more "Linux-like" on the forum, rather than how to use it effectively to solve smartphone-specific tasks...)
A toolkit for cross-compilation is available, so that one can try to package his favorite software.
Actually, it is able to do compilation locally on the device, but it seems not to be able to make a package locally.
Some things to know:
One needs Hacker's keyboard or something similar. One can't live here without Esc, Tab, Control. Or one could try to learn the Touch Keyboard.
vim ran with an encoding different from utf-8, and the Russian letters were displayed incorrectly. So, set encoding=utf-8 had to be written in .vimrc.
ssh to another computer at home couldn't login. The reason was simple: it used the username u0_a95 instead of one's usual username. (One can write User your_username in .ssh/config to permanently "fix" it.)
I'd recommend doing a research on XDA-Developers board

Trying to make uni-process device ... is this possible??? :(

Hy everyone, I'm Korean and a little short on using english so please try to understand if I say things not appropriate.
So, my status is that I have odroid-s.
What I'm trying to do for like month or more is that I want to make android to HelloWorld.
What I want to say is that, on the odroid-s, bootloader part, kernel part is the same but the framework part(which will be android), I'll remove all the android part and replace it with just HelloWorld program. The purpose of this HelloWorld program is to display HelloWorld on the screen.
What I think I discovered is that, as I 'vimdiff' bootlogs between normal bootlog and the one that I removed all the system partition part (which is android system partition part) is that android kernel's init goes on and executes console(/bin/sh), netd(bin/netd), ... and it enables adb and it completes his work.
So my conclusion is, I need to use Linux kernel that is non-modified and modify it for odroid-s, and use that kernel for my HelloWorld program!
What I want to ask is.... Am I doing it right?? T_T
My goal right now is to make HelloWorld come out from this odroid-s device...
Please somebody help me. If anybody don't understand what I wrote plz tell me, I'll fix it.
Thx for reading....
The modifications to the linux kernel are likely to be irrelevant to your goals, so you might as well leave them in place for simplicity.
Your biggest challenge is going to be output - where do you want to send it? If you had one of the devices that has (or can have with the right kernel config) a debug serial port, then it would be really easy to write something triggered by the init script (or even use 'echo' in the script) which outputs your message on that port.
But chances are you want to put something on the screen. This is going to be overwhelmingly more complicated, and perhaps device dependent. The way the android runtime does this for actual apps is going to be way more involved than you probably want to get into.
A more practical approach might be to look at how the boot animation is done. For starters you could just replace it with a static image that says "hello world". Once you can do that, the next step would probably be to find some character generator code. Finally you might want to implement scrolling and other terminal-like features.
As an alternative approach, there are builds of more traditional linuxes for some android devices - debian or ubuntu for example. These may include console implementations capable of displaying on the device screen.
As another idea, if you are flexible about how much of android you would be willing to leave on the device, you could build a version of the android terminal emulator example, modified to be a home screen replacement. You might be able to remove a lot of android components (eventually including the default home screen). Or on a secured device (ie, most consumer devices that haven't been rooted) you could just do the home screen replacement while leaving the actual system unmodified. It wouldn't be secure against users wanting to run other things, but generally the user would interact only with your code.

Categories

Resources