Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: Michael_Lee on April 17, 2011, 04:04:14 pm

Title: Programming on the Android smartphone
Post by: Michael_Lee on April 17, 2011, 04:04:14 pm
Did you know that you can program and run Python on nearly any Android smartphone?
You can literally whip out your phone and start programming on the run -- it's like a calculator on steroids! (although support for graphics is nearly nonexistant, as far as I can tell, so games are out)

http://code.google.com/p/android-scripting/

You can also do Lua, Perl, jRuby, and a few other languages, I think.

This is so awesome: I just had to share.
Title: Re: Programming on the Android smartphone
Post by: willrandship on April 17, 2011, 04:04:38 pm
That's because it's linux :P It rocks, right?
Title: Re: Programming on the Android smartphone
Post by: Michael_Lee on April 17, 2011, 04:25:53 pm
Yeah, Linux is awesome.

I really need to install a Linux distribution someday.
Title: Re: Programming on the Android smartphone
Post by: Jim Bauwens on April 17, 2011, 04:46:57 pm
Thanks for the link! This looks real awesome :)
Title: Re: Programming on the Android smartphone
Post by: alberthrocks on April 17, 2011, 04:51:37 pm
If someone could wrap the core Android GUI libraries with Python, it could work :)
Title: Re: Programming on the Android smartphone
Post by: tloz128 on April 17, 2011, 05:31:46 pm
Wow, I only thought you could program Java for it. I might want to look into this.
Title: Re: Programming on the Android smartphone
Post by: Juju on April 17, 2011, 05:37:24 pm
Well yeah, since Android is some sort of Linux distro, you can pretty much do anything with it.
Title: Re: Programming on the Android smartphone
Post by: tloz128 on April 17, 2011, 05:41:37 pm
Well yeah, since Android is some sort of Linux distro, you can pretty much do anything with it.
It actually runs on top of the Linux distro.
Title: Re: Programming on the Android smartphone
Post by: FinaleTI on April 17, 2011, 07:32:03 pm
Nice. I'm gonna have to look at that.
I did manage to setup a rudimentary Java programming environment on my Droid, through the use of an online IDE and an online compiler. Link that with my Dropbox, and I think it works quite nicely.
Title: Re: Programming on the Android smartphone
Post by: TC01 on April 17, 2011, 07:40:01 pm
I remember looking at this a while ago when beginning to mess around with Android development.

I wish there was a full port of the Android API to Python (or one of these other languages): this, and like the Jythonroid project which it seems to have supplanted, are really only for making scripts, not full-fledged applications.

Well yeah, since Android is some sort of Linux distro, you can pretty much do anything with it.
It actually runs on top of the Linux distro.

To be technical, it runs on top of the Linux kernel (Or at least a version of the Linux kernel modified by Google). It's not considered a Linux distro (at least, not by Google).
Title: Re: Programming on the Android smartphone
Post by: Munchor on April 18, 2011, 05:51:35 am
Python? Me too thought it was Java only. They're introducing Flash on 3.2.
Title: Re: Programming on the Android smartphone
Post by: PeonHero on April 19, 2011, 07:33:22 pm
Is there any other device that can do this? What other devices are there that a person can program on the run, I only know two things you can program on, TI calculators and android smart phones, any others?
Title: Re: Programming on the Android smartphone
Post by: willrandship on April 19, 2011, 08:26:05 pm
Other calcs, laptops :P The pandora. Netbooks too, but I guess they're laptops :P

@tloz "on top of" means it runs on linux. Same thing as saying Fedora runs on Linux, or Ubuntu. They just made a Java-centered Linux OS.
Title: Re: Programming on the Android smartphone
Post by: Binder News on April 19, 2011, 09:17:47 pm
I personally prefer working on my laptop, although the testing is a little annoying as if the emulator crashes, it takes a little while to start it up again.
Title: Re: Programming on the Android smartphone
Post by: PeonHero on April 19, 2011, 11:09:45 pm
So far nothing beats the calculator for programming on the go I guess. Laptops are great but not as portable (you can't take them everywhere like calculators), but the TI calculators are amazingly well designed, the buttons are so easy to get used to yet it looks complicated, I love it. It's looks like what a real professional programmer would use on the go, I think people also look smarter / nerdier while they're using it. If they had cell phone capability, web browsing capabilities, able to take pictures and videos, were in color, and you could program in more than just TI-Basic, it would be the best thing ever made (in my opinion).

Maybe it will be made in the future, something like "The Pandora," it would be the size of 2 TI-83s held sideways (like a ds) and you can open it up to reveal a full sized screen as big as a ti-83 and a keyboard as big as a ti-83. It wouldn't have a QWERTY keyboard though because that would take up too much important button space. you would have to alpha-lock just like in the TI calculators to use it, but it would be in QWERTY to make it easier. There would be two analog arrow keys for games (I guess like "The Pandora" except it would be normally hidden under regularly used buttons, and you can flip it from beneath some buttons when you're playing games, and it'll have other buttons under than flip too).

Sounds cool right? I want to make this someday, when I'm in college (I'm gonna start during the summer right before my Sophomore year). In the meantime, I'm going to master learning how to program in PHP, java, axe and ruby (C++ too?) first. I think I'm dreaming too much, but I still think it's possible. I'm just not knowledgeable enough at the moment, I don't feel ready to make something like this, this very second. We'll see what happens 3 years into the future, hopefully the world doesn't end next year though, but then again, a lot of people are going to throw parties... and you know, can't wait for that either...
Title: Re: Programming on the Android smartphone
Post by: willrandship on April 20, 2011, 12:25:13 am
Only thing is the internals suck for what they charge.

Too much flipping stuff means it will wear out extremely quickly. I recommend a 2nd Lock style approach instead, and having dedicated arrow keys. They won't take too much space. Don't forget you'll get more buttons by having only the screen on the top, and the entire 83+ surface area on the bottom.
Title: Re: Programming on the Android smartphone
Post by: DJ Omnimaga on April 20, 2011, 12:28:50 am
The issue with a calculator with cellphones capabilities though is that it would quickly get banned from school. Some cellphones are, already, due to disturbing classes, and people could just text each others the answers.

Otherwise, if there are no cellphone capabilities there is always UberGraphX which Uberspire is currently working on.
Title: Re: Programming on the Android smartphone
Post by: Netham45 on May 13, 2011, 09:22:38 pm
Oh hey, I'd been thinking of trying to compile Python on it myself, this will save me a bunch of time. :P
Title: Re: Programming on the Android smartphone
Post by: ruler501 on May 13, 2011, 10:44:48 pm
You can actually compile Python on the Android?

EDIT: I don't own an android but I'm going to try writing an output function for it. Liek the one in TI-Basic on the 84
does anyone know how many chars on a line in a python app on the android? and how many lines there are on the screen?
Title: Re: Programming on the Android smartphone
Post by: Michael_Lee on May 14, 2011, 01:01:36 pm
You can actually compile Python on the Android?

EDIT: I don't own an android but I'm going to try writing an output function for it. Liek the one in TI-Basic on the 84
does anyone know how many chars on a line in a python app on the android? and how many lines there are on the screen?

I don't know if you can compile (if you can, it would be complicated), but you can run scripts using an interpreter.

When held vertically, the default amount of chars per line (on the output console) is 80, unless the user resized it.

Note that at this moment, any Python you write for the android has to be compatible with Python 2.6.2
Title: Re: Programming on the Android smartphone
Post by: ruler501 on May 14, 2011, 01:29:56 pm
How many Lines on the console?
I writing in python 2.6 so my code should be compatible.
Title: Re: Programming on the Android smartphone
Post by: Michael_Lee on May 14, 2011, 01:36:04 pm
With keyboard showing:
 80 chars x 34 lines

Without keyboard showing:
 80 chars x 58 lines
Title: Re: Programming on the Android smartphone
Post by: ruler501 on May 14, 2011, 01:36:55 pm
Are there any good emulators I can use for free to test this?

EDIT: also how would I load the python file to it. Do i nee to run some kind of a script on it efore loading
Title: Re: Programming on the Android smartphone
Post by: Michael_Lee on May 14, 2011, 01:40:04 pm
Are there any good emulators I can use for free to test this?

EDIT: also how would I load the python file to it. Do i nee to run some kind of a script on it efore loading

Sorry, I don't know any emulators.  I do know that there are free ones floating around, its just that I've never gotten around to finding one and setting it up.

Loading the python file: either type it in or do some sort of transfer thing.  You don't need to do anything special to get most code to run (except graphics -- not sure how that's going to work out)
Title: Re: Programming on the Android smartphone
Post by: ruler501 on May 14, 2011, 01:49:49 pm
I'm running it TI-BASIC like with Output command.
How do you get input with python on the android?
Title: Re: Programming on the Android smartphone
Post by: Michael_Lee on May 15, 2011, 06:09:01 pm
I suppose one way would be to use 'raw_input()' or something.

If you want to use the actual android input methods, try this:
Code: [Select]
# No shebang necessary.

# You need these only if you want to use the android API.
import android
droid = android.Android()

# both the title and message are optional parameters.
title = "Name"
message = "Enter your name here:"

# Creating the input
droid.dialogCreateInput(title, message)
droid.dialogSetPositiveButtonText("Submit")
droid.dialogShow()

# Getting the response
response = droid.dialogGetResponse().result["value"]

print response

This uses the default input box.

See http://code.google.com/p/android-scripting/wiki/ApiReference for more info.
Title: Re: Programming on the Android smartphone
Post by: Binder News on May 15, 2011, 06:11:13 pm
If you need an emulator, download and install the Android SDK. It includes an emulator.
Title: Re: Programming on the Android smartphone
Post by: ruler501 on May 15, 2011, 06:38:18 pm
I did that. How do you get key inputs?

I have a simple output and ClrHome functions working now(sound familiar_)

EDIT: I forgot the code to send a python program to the android emulator. does anyone know what it is?