Share Code

by Mitch » Fri, 07 Aug 2009 12:50:55 GMT

Sponsored Links

I've been told posting general questions is not a good idea, but I've
had some luck so I'll try again.  SInce this is a general question,
general answers are fine.

I'm working on an idea for a game and was wondering if it's possible
in Android.  It's basically an ad-hoc game so that 2 (or more) people
with android devices could play even if only 1 person has the app.
This game would involve sharing both data and code.  I think the data
sharing is possible.  What I think may be difficult is the sharing of

I've read some postings asking why one would want to share code, so
I'll answer that before you ask. The main reason is that the each
player of this game actually would write code (albeit often simple
code) and transmit it to the device hosting the game.  I could develop
my own language and transmit the instructions that way as data, but it
seems better to transmit the Java bytecode that would run on the phone
since I would include library functions they could call to perform
common actions.  For example a user might write this upon entering a
virtual room and spotting an enemy:

while (enemy.isalive()) {

if (health()<0.2) {

Also, having lived in areas where there is poor phone service I know
that being able to transmit directly to the person sitting next to you
in the car or while camping in nowhereland would be a good feature
regardless.   So even if I decide to transmit the user written code as
data, getting the original app from the web might not be reasonable in
some cases.  If transmitting code isn't reasonable, I still think the
app will work, it would just cause me to write it differently.


Is it reasonable/possible to directly share user written code?
Is it reasonable/possible to directly transmit an app directly from
one device to another?
What options exist for transmitting data and/or code?
If transmitting Java bytecode isn't reasonable, how does one go about
directly transmitting data to another phone?

In this game, one device would host the code written by all players
while the results of running the code would be updated on all devices
(if that's helpful).  So really only one person need have the total
app that's purchased.  Everyone else could have a free version that
didn't host the program's execution but allowed for writing
instructions, transmitting to the host and reading back the results as
it happens.

I would only expect you to point me in a reasonable direction and/or
post a link to the info that will answer these questions, even if only
partially.  So while I appreciate details, don't go nuts unless you
like that sort of thing.

Thanks in advance.


Share Code

by Mark Murphy » Fri, 07 Aug 2009 18:34:46 GMT


Java/Dalvik bytecode? No.

Android Scripting Environment scripts? Probably -- haven't played with
it yet.

SIMPLE language scripts? Perhaps -- haven't played with it either.

Directly using a scripting engine like Beanshell? Yes, once you get a
Dalvik-friendly edition.

If by "app" you mean a full-fledged Android APK, no.

Name an Internet protocol (HTTP, SMTP, FTP, XMPP, etc.), and given
sufficient effort, you can probably get it working.

The challenge is if you are trying to avoid an intermediary server.
Having device A upload to a server (e.g., HTTP) and device B download
from the same server is easy. It may not be possible for device A and
device B to directly talk to each other, particularly if they are not
both on the same WiFi subnet.

Ideally, you don't -- you use an intermediary server.

If I were you, I'd focus on a scripting language and some sort of
HTTP-based exchange via some rented Web host, at least for the prototype
of your app.

Mark Murphy (a Commons Guy)  | 

Android Development Wiki: 


Sponsored Links

Other Threads

1. Delayed actions


I am trying to get 4 sounds to play in sequence.   Something along the
lines of:


Is there a way to add delay in Android or to schedule an action in the
future?  Thanks for any help.


2. debug certificate expire. What to do?

Hi i'm a newby in android programming.

I'm using a Mac OSX leopard and using eclipse europa

I tried compiling my  first android app and an error appears in the  
console saying

  - Android Launch!
  - adb is running normally.
  - Could not find simpleflashlight.apk!

and it saids my certificate expired.

I searched the internet and they said to change my "time and date" and  
to "delete the file debug.KEYSTORE."
  The problem is i cant find the file debug.KEYSTORE  anywhere in my  
I tried deleting it by using terminal but there must be typing wrong  
because it saids "command line not found" in the terminal
i couldn't locate the file anywhere in my computer.
i typed "sudo ~/.android/debug.keystore"
can anyone please help me!
Thank You


3. RE : Possible in emulator? Querrying google map? Unlocking Anrdoid Example

4. Multi threading in android

5. surfaceCreated() and CreateSurface() in camera preview application

6. Change Android Language

7. android list targets FAILS