Share Code

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


Sponsored Links
 Hi,

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
code.

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()) {
   swing(weapon);
   duck();
}

if (health()<0.2) {
  drink(potion);
}

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.

Summary:

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)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Development Wiki:  http://wiki.andmob.org 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. using text fields with suggest autocompletion

When typing in fields with an automatic suggest list for
autocompletion (ex. google search), is it possible to pick a
suggestion and complement it (continue typing in the field), instead
of directly submitting the information (ie. launch the google search)
?
I often need it, for example to redo a previous search but adding
criteria, or correcting some. Or when you mistyped an URL, to avoid
retyping it entirely but be able to correct...

On my desktop I can, for example by selecting the suggestion with
arrows, and just continue typing after. But with only a touchscreen I
could not find a way yet....

--~--~---------~--~----~------------~-------~--~----~

2. App upgrade (with zipalign) causes force closes/disappearing of app icon

Hi,
Almost all our users complain that after upgrading to the newest
version of our "Camera Pro" app, either the app crashes or the icon is
not showing up anymore in the home screen. The problem seems to be
gone after deinstalling and reinstalling the app.
How can it be possible that the icon is gone? This is the first
version we used zipalign on, can this have something to do with it?

Thanks,
Swiss Codemonkey team

--~--~---------~--~----~------------~-------~--~----~

3. Telephony API

4. Dalvik virtual machine

5. Activity Closing, Task affinity

6. changing default orange selection...