Office Hours — Today, February 21

Thursday, February 16

Mark M.
has entered the room
Mark M.
turned on guest access
tunneling
has entered the room
Mark M.
howdy, tunneling!
how can I help you today?
tunneling
howdE
oh .. i have so many questions .. lol
i was looking at your MergeAdapter build.xml file trying to figure out how to make a jar file
i downloaded your source, but couldn't figure out how to generate the jar
Feb 21
7:30 PM
Mark M.
ant jar, probably
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?
build.xml is for Ant
tunneling
ok. let me start over.
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
I would presume that there is a way
tunneling
ok
Mark M.
what you see with MergeAdapter is *two* projects
the Android library project
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
right now, I use Komodo Edit for non-Android work
7:35 PM
tunneling
ic
i've read that you can add an Ant file to the build path in eclipse
I tried it today, but to no avail.
Mark M.
I would find that somewhat surprising
the build path is supposed to be JARs that go into your project
I have no idea why a build.xml would be found there
but, then again, I am not an Eclipse expert
tunneling
sorry, Builders
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
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
I'd love to add it to the SD card of a device
Mark M.
that's a massive security hold
er, hole
tunneling
yea.. i know
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
as it will handle resources and such as well
AFAIK, the R17 tools should support this
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
that's been discussed
tunneling
ah
Mark M.
but I do not know if it is an anticipated feature or not
7:45 PM
tunneling
ic
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
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
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>
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.
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
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"
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
I mean, if this were traditional Java, ServiceLoader is probably a fine solution
but this is Android
as you noted, META-INF/services is problematic
so, why bother?
tunneling
because I can't think of another way to achieve what I've set out to do
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
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
lol
true
good point
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
at least, AFAICT
oh, no, wait, that might work
tunneling
that jar file is in the class path
Mark M.
I'm still dubious of the value
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
yes, these transcripts are archived, with the links published to the cw-android Google Group
tunneling
ok
maybe that's the way I'll have to go
Mark M.
what do these drivers drive?
IOW, is there a reason you are doing integration-by-JAR rather than integration-by-Intents?
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"
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()
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
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..
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
some of them may be app authors, that already have apps that "send and receive commands from a remote source"
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
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?
8:10 PM
Mark M.
there are two types of discovery
1. the user finding what plugins they need
2. the app finding what plugins exist
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
then the app find them
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
exactly
Mark M.
so, if the user is installing plugins, somehow you need to provide them a directory of what plugins exist
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
you may want to read the Integration and Introspection chapter in _The Busy Coder's Guide to Advanced Android Development_)
(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
ahh
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
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
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
or use an RSS feed
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
but an XML-based format would work as well
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
oh
tunneling
so i guess the market will supply the data in the JSON format?
Mark M.
no
first, I don't know what "the data" is
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
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.
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.
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
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
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)
oh, yeah, that problem
tunneling
haha
i guess it's a socket timeout
Mark M.
that's very possible
Google had to do a heartbeat every 30 minutes for the stuff behind C2DM
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
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
8:30 PM
Mark M.
well, if the phone is asleep, you're screwed either way
8:30 PM
tunneling
yea.. that's what I found.
Mark M.
you will need a WakeLock and a WifiLock
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
so does it just stop executing code?
Mark M.
yes
while incoming packets on a mobile data connection will wake up the device, that's not trye for WiFi
er, true
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
so on mobile or wifi, i lose connection
Mark M.
right, though that's more a hardware-specific thing
there isn't something magical about five minutes for, say, a SIP server
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

Thursday, February 16

 

Office Hours

People in this transcript

  • Mark Murphy
  • tunneling