Mark M. | has entered the room |
Mark M. | turned on guest access |
tunneling | has entered the room |
Mark M. |
howdy, tunneling!
|
Mark M. |
how can I help you today?
|
tunneling |
howdE
|
tunneling |
oh .. i have so many questions .. lol
|
tunneling |
i was looking at your MergeAdapter build.xml file trying to figure out how to make a jar file
|
tunneling |
i downloaded your source, but couldn't figure out how to generate the jar
|
Feb 21 | 7:30 PM |
Mark M. |
ant jar, probably
|
Mark M. |
yup, that's it
|
tunneling |
so if I make a build.xml and add it to the build path, shouldn't it run everytime it compiles?
|
Mark M. |
huh?
|
Mark M. |
build.xml is for Ant
|
tunneling |
ok. let me start over.
|
tunneling |
i want to have a project in eclipse that ends up in a jar file, and uses the Android api
|
Mark M. |
purely from Eclipse, I do not know how to do that, as I am not an Eclipse expert
|
Mark M. |
I would presume that there is a way
|
tunneling |
ok
|
Mark M. |
what you see with MergeAdapter is *two* projects
|
Mark M. |
the Android library project
|
Mark M. |
and the demo/ sub-project
|
tunneling |
yea
|
Mark M. |
what I do is use both in Eclipse
|
tunneling |
ok
|
Mark M. |
and when I commit/push/tag a change and wish to distribute a new JAR, I run the ant jar command from the command line
|
tunneling |
oh
|
Mark M. |
I use Eclipse because the world is forcing me to, not by personal preference :-)
|
tunneling |
what do you prefer?
|
Mark M. |
a simple editor
|
Mark M. |
right now, I use Komodo Edit for non-Android work
|
Feb 21 | 7:35 PM |
tunneling |
ic
|
tunneling |
i've read that you can add an Ant file to the build path in eclipse
|
tunneling |
I tried it today, but to no avail.
|
Mark M. |
I would find that somewhat surprising
|
Mark M. |
the build path is supposed to be JARs that go into your project
|
Mark M. |
I have no idea why a build.xml would be found there
|
Mark M. |
but, then again, I am not an Eclipse expert
|
tunneling |
sorry, Builders
|
tunneling |
you declare it as a Builder (don't forget, i'm a Novice. especially when it comes to vocabulary)
|
Mark M. |
I have never worked directly with Eclipse builders, so I can't help you there, either
|
tunneling |
ok
|
Feb 21 | 7:40 PM |
tunneling |
so the big picture is that I'm trying to develop
this app that will allow me to drop in jar files. these jar files
contain "Drivers" that are written to an API that I am developing.
|
Mark M. |
define "drop in"
|
tunneling |
oh.. someone writes the Driver, sends it to me and I'll add it to the libs folder in Eclipse, then add it to the Build Path
|
tunneling |
I'd love to add it to the SD card of a device
|
Mark M. |
that's a massive security hold
|
Mark M. |
er, hole
|
tunneling |
yea.. i know
|
tunneling |
that's why i'm not going there
|
Mark M. |
eventually (and hopefully soon), Android library projects will support distributing them in JAR form
|
tunneling |
that would be nice
|
Mark M. |
that will be the long-term reusable component container for Android
|
Mark M. |
as it will handle resources and such as well
|
Mark M. |
AFAIK, the R17 tools should support this
|
Mark M. |
whenever they are released
|
tunneling |
yea, it would be really cool if you didn't have to modify the manifest.. will it read the manifest in the library project?
|
Mark M. |
not that I am aware of
|
Mark M. |
that's been discussed
|
tunneling |
ah
|
Mark M. |
but I do not know if it is an anticipated feature or not
|
Feb 21 | 7:45 PM |
tunneling |
ic
|
tunneling |
ok, so the next thing I was going to ask you about is really a Java question and it has to do with the ServiceLoader
|
tunneling |
I guess you haven't played with it much, so I think I am 0 for 2 so far.
|
Mark M. |
I have never used it
|
Mark M. |
it's in the Android SDK, so in theory it might work
|
tunneling |
yea.. so you have to have this META-INF/services/<fully qualified class name>
|
tunneling |
that's another reason i'm interested in the jar
stuff. since android doesn't like me making this folder, i'd like to be
able to insert /services/<full qualified class name> into the apk.
|
tunneling |
right now i have to make the apk, then open it up,
then insert the goodies, then use "adb install .. " to load the apk
into the emulator
|
Mark M. |
that's part of the reason why I am skeptical that it will work
|
Feb 21 | 7:50 PM |
tunneling |
so the ServiceLoader will goto this folder, read
the <fully qualified class name> file, and get the full qualified
class names of the classes that implement the "Service" in my case it
would be a "driver"
|
tunneling |
this is the way that java.sql works.
|
Mark M. |
seems kinda silly to me
|
tunneling |
lol
|
Mark M. |
if you have to write a file, why not write a Java file instead of an XML file?
|
tunneling |
it's plain text
|
Mark M. |
big <bleeping> deal
|
tunneling |
woah
|
Mark M. |
if nothing else, write a script to code-gen the Java from a plain text file
|
tunneling |
well.. the beauty of it is that the ServiceLoader will "load" all of the service providers (drivers)
|
Mark M. |
so would a Java class
|
Mark M. |
I mean, if this were traditional Java, ServiceLoader is probably a fine solution
|
Mark M. |
but this is Android
|
Mark M. |
as you noted, META-INF/services is problematic
|
Mark M. |
so, why bother?
|
tunneling |
because I can't think of another way to achieve what I've set out to do
|
tunneling |
I want my app to load the drivers without having to know what they are
|
Mark M. |
your app has to know what they are for ServiceLoader
|
Feb 21 | 7:55 PM |
Mark M. |
or do you think out-of-work Keebler elves are writing that text file?
|
tunneling |
no.. it only has to know the interface
|
tunneling |
lol
|
tunneling |
true
|
tunneling |
good point
|
tunneling |
it's actually the Underpants Gnomes that write my text files
|
Mark M. |
that's my point: the incremental value of the text
file (vs. a Java class) IMHO isn't worth the pain of dealing with
Android's build tools and META-INF/services/
|
tunneling |
the text file should go in the jar file which is the driver
|
Mark M. |
that wouldn't work
|
Mark M. |
at least, AFAICT
|
Mark M. |
oh, no, wait, that might work
|
tunneling |
that jar file is in the class path
|
Mark M. |
I'm still dubious of the value
|
Mark M. |
you already indicated that you have to modify the app to have the driver (copy JAR and rebuild)
|
tunneling |
do you publish these transcripts?
|
Mark M. |
adding a line to a Java class to instantiate your new driver seems like the simplest solution
|
Mark M. |
yes, these transcripts are archived, with the links published to the cw-android Google Group
|
tunneling |
ok
|
tunneling |
maybe that's the way I'll have to go
|
Mark M. |
what do these drivers drive?
|
Mark M. |
IOW, is there a reason you are doing integration-by-JAR rather than integration-by-Intents?
|
Feb 21 | 8:00 PM |
tunneling |
i've just run down the path of "i want to build an app that supports plug-ins".. and that's where I ended up
|
Mark M. |
OK, what do the plug-ins do, in general terms?
|
tunneling |
the drivers will handle sending and receiving commands from a remote source
|
Mark M. |
another approach, therefore, would be for the
plug-ins to be distributed as separate APKs, exposing some Intent-based
interface for "sending and receiving commands from a remote source"
|
Mark M. |
e.g., to send a command via the plug-in, call
startService() to send the command to an IntentService, supplying a
PendingIntent for delivering the result
|
tunneling |
is that aidl?
|
Mark M. |
no, that would be bindService()
|
Mark M. |
that's also an option
|
tunneling |
i found the aidl section of your book, but haven't read it yet
|
Mark M. |
I personally prefer the command pattern and startService(), but binding has its adherents as well
|
Feb 21 | 8:05 PM |
tunneling |
ok, i need to think about how to implment it. one of my concerns is that there could potentially be many drivers.
|
Mark M. |
how many drivers will a typical user need?
|
tunneling |
maybe 10
|
Mark M. |
and you are expecting to get 10+ other developers to write drivers for you?
|
tunneling |
possibly, or I'll write them myself..
|
tunneling |
that's undetermined
|
Mark M. |
are these other developers independent app
authors, or is it something where you will be directing their
development work (e.g., they are contractors)?
|
tunneling |
now, avaliable, there could be hundreds of drivers.. but a typical User may only need about 10
|
tunneling |
some of them may be app authors, that already have apps that "send and receive commands from a remote source"
|
tunneling |
i guess deciding how/who writes the drivers will ultimately be a business decision
|
Mark M. |
well, beyond that, there's all sorts of discovery issues and so forth
|
Mark M. |
IMHO, for something like this, you count: 0, 1, 2, 3, 4, 5, 6, 1 million, infinity
|
tunneling |
so if I go the Intent route, how does the main app locate the ... is that discovery?
|
Feb 21 | 8:10 PM |
Mark M. |
there are two types of discovery
|
Mark M. |
1. the user finding what plugins they need
|
Mark M. |
2. the app finding what plugins exist
|
Mark M. |
in your JAR-integration approach, neither of those are an issue, as you are forcing a solution
|
tunneling |
well.. i think the User would have to install the plugins
|
tunneling |
then the app find them
|
tunneling |
oh, that's what you said
|
Mark M. |
if the user is installing the plugins, the only choice is integration-by-Intents, IMHO
|
tunneling |
right
|
Mark M. |
your JAR approach would not have the user install the plugins, as they would all be baked into the APK
|
tunneling |
right
|
tunneling |
exactly
|
Mark M. |
so, if the user is installing plugins, somehow you need to provide them a directory of what plugins exist
|
Mark M. |
then, given that they install some plugins, your app needs to find them
|
tunneling |
right
|
Mark M. |
the latter would be accomplished mostly via PackageManager
|
tunneling |
ok
|
Mark M. |
exactly what you use on PackageManager would depend somewhat on what you are using for the integration
|
Mark M. |
you may want to read the Integration and Introspection chapter in _The Busy Coder's Guide to Advanced Android Development_)
|
Mark M. |
(minus the extra closing parenthesis)
|
tunneling |
ok
|
Mark M. |
in the last update, I just added a section on creating an APK-based plugin mechanism
|
tunneling |
i'll do that when we are done here
|
tunneling |
ahh
|
tunneling |
ok
|
Mark M. |
in that case, it was using RemoteViews passed around via broadcasts
|
tunneling |
what about security?
|
Mark M. |
I cover some security stuff in the chapter
|
Mark M. |
so, while the RemoteViews-specific stuff probably isn't relevant for you, some of the rest will be
|
tunneling |
ok
|
Mark M. |
in my next update, due out in a week or two, I
will have another section in there on using ContentProviders for a
plugin interface
|
tunneling |
I guess in the main app, I could provide an list of avaliable plugins with links to the market
|
Feb 21 | 8:15 PM |
Mark M. |
and that could be driven by, say, a JSON file you download from the mother ship
|
tunneling |
oh?
|
Mark M. |
sure
|
Mark M. |
or use an RSS feed
|
Mark M. |
whatever floats your boat
|
tunneling |
ok.. i've seen JSON thrown around, but have no idea what it is
|
Mark M. |
JavaScript Object Notation
|
tunneling |
or how to use it :)
|
Mark M. |
basically, it's a data structure in text format, a bit lighter-weight than XML
|
Mark M. | |
Mark M. |
but an XML-based format would work as well
|
Mark M. |
JSON is the flavor of the month for this sort of thing, but it's not required
|
tunneling |
more reading .. i need to quit my day job
|
Mark M. |
regardless, you could download your list of plugins and their Market links in some data format
|
Mark M. |
oh
|
tunneling |
so i guess the market will supply the data in the JSON format?
|
Mark M. |
no
|
Mark M. |
first, I don't know what "the data" is
|
Mark M. |
second, the Market doesn't have a documented and supported API of any form
|
tunneling |
oh.. the list of plugins
|
Mark M. |
outside of Market URLs
|
tunneling |
is the Mother Ship my Mother Ship?
|
Mark M. |
yes
|
tunneling |
I thought you meant Google = Mother Ship
|
Mark M. |
oh, sorry
|
tunneling |
gotcha
|
Mark M. |
see, I've been kinda thinking throughout all of this that this was a major project with a large team at a big firm
|
Feb 21 | 8:20 PM |
tunneling |
haha.. it's a major project, but a small team
|
Mark M. |
no offense, but your plugin problem perhaps is less a technical one and more a marketing one
|
tunneling |
i can develop the plugins
|
Mark M. |
you're going to have to, at least at the outset
|
tunneling |
yea.
|
Mark M. |
getting developers to support some plugin interface to your app will take some work
|
tunneling |
i would love to just spill the beans, but I think I
have a really unique idea and since this transcript is published it
makes me nervous.
|
tunneling |
we talked before about developing an Open Source
"Service with WIFI lock to maintain a persistent connection", maybe we
should talk about it offline, but I would like to pursue that.
|
Feb 21 | 8:25 PM |
Mark M. |
yeah, that's something worth covering in the books
|
tunneling |
and it will really help with the plugins ;)
|
Mark M. |
I can work up a sample that uses a Comet-style HTTP long poll, or perhaps MQTT, as the protocol
|
Mark M. |
did you have a particular protocol (plugin-to-remote source) in mind?
|
tunneling |
umm.. i do, but it requires hardware.
|
Mark M. |
yeah, well, that won't work for my case
|
tunneling |
yea
|
Mark M. |
anyway, I've added that to my list of things to write up in the March/April timeframew
|
Mark M. |
er, timeframe
|
tunneling |
basically i connect to a remote source that requires you to talk to it at least once every 5 minutes
|
Mark M. |
(one of these days, I'll figure out why damn near all my typos are on the last words of my sentences)
|
Mark M. |
oh, yeah, that problem
|
tunneling |
haha
|
tunneling |
i guess it's a socket timeout
|
Mark M. |
that's very possible
|
Mark M. |
Google had to do a heartbeat every 30 minutes for the stuff behind C2DM
|
Mark M. |
and it took some work to get it as long as every 30 minutes
|
tunneling |
so the issue is when the "internet" isn't working on an Android device, the "Connection is reset by peer"
|
Mark M. |
right
|
Mark M. |
and since this is hardware, I'm assuming it's gotta be WiFi, not mobile data (e.g., 3G), right?
|
tunneling |
and if the phone is asleep, and my Connection
doesn't know that the connection has been reset, the remote source can't
send messages
|
Feb 21 | 8:30 PM |
Mark M. |
well, if the phone is asleep, you're screwed either way
|
Feb 21 | 8:30 PM |
tunneling |
yea.. that's what I found.
|
Mark M. |
you will need a WakeLock and a WifiLock
|
Mark M. |
with commensurate pain from a battery standpoint
|
tunneling |
I have all of these nice Exceptions that notify
when the connection is lost, but when the phone goes to sleep.. it seems
like the app just stops running.. and the exceptions are never called
because my Ping thread is asleep
|
Mark M. |
when the phone goes to sleep, the CPU shuts down
|
tunneling |
yea
|
tunneling |
so does it just stop executing code?
|
Mark M. |
yes
|
Mark M. |
while incoming packets on a mobile data connection will wake up the device, that's not trye for WiFi
|
Mark M. |
er, true
|
Mark M. |
perhaps WiFi Direct will change some things in this area
|
tunneling |
but my outgoing Ping isn't sent, so the Connection is reset by peer and the incoming packets stop coming
|
tunneling |
so on mobile or wifi, i lose connection
|
Mark M. |
right, though that's more a hardware-specific thing
|
Mark M. |
there isn't something magical about five minutes for, say, a SIP server
|
Mark M. |
anyway, that's a wrap for today's chat
|
tunneling |
yea, I think it's a unique problem
|
Mark M. |
next one is Tuesday, 4pm Eastern
|
tunneling |
ok, bye. thanks for everything.
|
Mark M. |
have a pleasant day!
|
tunneling | has left the room |
Mark M. | turned off guest access |