May 1 | 9:50 AM |
Mark M. | has entered the room |
May 1 | 9:55 AM |
Mark M. | turned on guest access |
May 1 | 10:00 AM |
Jumana A. | has entered the room |
Jumana A. |
hi mark!
|
Mark M. |
howdy, Jumana!
|
Mark M. |
how can I help you today?
|
Jumana A. |
going ok
|
Jumana A. |
ive been waiting for this session!
|
Jumana A. |
i have a few questions to shoot! :-)
|
Mark M. |
go ahead
|
Bruce F. | has entered the room |
Jumana A. |
Mark, my app is something like " a quote a day"
where random quotes are displayed - one new one everyday (well thats
what atleast i want to be able to do!i have a long way to go). Now when
these quotes are displayed, I also want to give the user the option of
sending it by email. For that Im providing them an image button to click
on. On click of which, the user will be shown all email clients that
have been installed on his device. How do i do that, mark? I gathered
from all your posts in stackoverflow, that you are not a big fan of
restricting users to share via sms or email only. And i totally agree
with you. But i really need to provide him only the email options :-)
|
Justin M. | has entered the room |
Mark M. |
use ACTION_SENDTO and a mailto: Uri of the specific person to email it to
|
Jumana A. |
The clients will not be shown in that case?
|
Mark M. |
what "clients"?
|
Jumana A. |
email clients like gmail/ yahoo mail
|
Mark M. |
(BTW, howdy, Bruce & Justin! be with you shortly)
|
Mark M. |
first you say you only want email options, now you say you want to block email options
|
Mark M. |
which is it?
|
Jumana A. |
im sorry if im not clear - i want the user to be shown the gmail, yahoo options on click of that button
|
Mark M. |
then use ACTION_SENDTO and a mailto: Uri of the specific person to email it to
|
May 1 | 10:05 AM |
Jumana A. |
ok will try that
|
Mark M. |
let me take questions from others, and I will come back to you in a bit
|
Jumana A. |
sure
|
Mark M. |
Bruce: do you have a question?
|
Bruce F. |
Yes, and hello Mark.
|
Bruce F. |
My question is about reusing ActionBarSherlock, or
any other library, between workspaces. I'm just recompiling every time I
start a new workspace. Is there a better way?
|
Mark M. |
beats me
|
Mark M. |
I only use one workspace
|
Mark M. |
I use working sets, not workspaces, to organize my projects
|
Mark M. |
you might try asking that on the ABS Google Group
|
Mark M. |
somebody there probably uses multiple workspaces
|
Mark M. |
sorry I could not help on that one
|
Bruce F. |
I'll probably just use working sets instead.
|
Bruce F. |
as soon as I figure out how to do that
|
Mark M. |
AFAIK, you'd use multiple workspaces if you have lots of different plugins, or need different Eclipse settings
|
Mark M. |
working sets are just ways of only showing a subset of projects in the Package Explorer
|
Mark M. |
Justin: do you have a question?
|
Justin M. |
I do, it's a little more general....
|
Justin M. |
Kind of an architecture question. I'm working on a
project where I've been separating out major areas of responsibility of
the app into separate services...
|
May 1 | 10:10 AM |
Justin M. |
I know I've read that there shouldn't usually be a need for more than one service in an application...
|
Justin M. |
One of the services is derived from Service and
the other from IntentService that I have right now, and both make sense
to use those respective superclasses based on what they're doing...
|
Justin M. |
But I'm wondering if I'm going to run into any problems if I had any more services than these two in the app?
|
Justin M. |
This is really not a specific question
|
Mark M. |
I would not say you will encounter "problems"
|
Justin M. |
Just looking for some general guidance. I can supply more info to clarify if that helps
|
Mark M. |
however, it is dubious whether you will get any value out of having more services than that
|
Mark M. |
having the two you describe, with different base classes, makes sense
|
Mark M. |
bear in mind that business logic does not have to be implemented on a subclass of Service
|
Mark M. |
too many developers think that Activity, Service, et. al. are means of code organization
|
Justin M. |
One controls a socket where I'm listening for connections and receiving requests (the Service-derived class)...
|
Mark M. |
they're not
|
Justin M. |
And the other then processes the requests in a FIFO fashion (the IntentService-derived class)
|
Mark M. |
right, and those function sufficiently differently (e.g., lifetime) that you need them separated as they are
|
Mark M. |
or, more accurately, while you could drop the
IntentService and roll your own FIFO queue in your other service, that
doesn't buy you anything.
|
Justin M. |
OK, that's good then... If I want to then send
HTTP requests to a server and then receive responses, that's where I was
thinking of a third service....
|
Mark M. |
why would that not be another capability of your existing IntentService?
|
Justin M. |
OK, actually that's what I was going to ask
|
Justin M. |
Because that's really what an IntentService would be good for then...
|
Mark M. |
something in the commands (Intents to onHandleIntent()) distinguish the cases
|
May 1 | 10:15 AM |
Mark M. |
if it's too much code, then refactor the business logic into some sort of command-handler classes
|
Mark M. |
the only downside of an IntentService being overloaded this way is that you only have one background thread
|
Mark M. |
so multiple commands cannot be processed in parallel
|
Mark M. |
one of these days, I'll get around to writing an
AsyncService that uses the thread-pool flavor of AsyncTask to give you
IntentService semantics with multiple threads
|
Justin M. |
So I shouldn't be concerned that the service is
going to be doing unrelated types of functionality then? Just use the
appropriate service based on whether I want to process requests in a
queue or as something long-running with state?
|
Mark M. |
pretty much
|
Mark M. |
again, Service is not a unit of code organization
|
Mark M. |
*classes* are the unit of code organization
|
Mark M. |
if a Service gets too complex, refactor business logic into other classes, not other services
|
Mark M. |
let me take questions from the others, and I'll swing back to you in a bit
|
Justin M. |
OK, fair enough. I have to think it through, but I
think it would be OK for processing received data and then outgoing
HTTP request/responses to be queued together (i.e. not running in
parallel)
|
Justin M. |
OK, I'm done actually, thanks a bunch!
|
Mark M. |
Jumana: do you have another question?
|
Jumana A. |
when the user is shown the quote for the day, I
want the user to be able to pinch the screen so that the font size
becomes smaller or bigger. is that possible to be implemented?
|
Mark M. |
you could use a GestureDetector to detect the pinch, then call setTextSize() as needed, I suppose
|
Mark M. |
or, if you are rendering the quote in a WebView, use its standard zoom capability
|
Jumana A. |
no its not webview
|
Jumana A. |
its in a scroll view, textview
|
May 1 | 10:20 AM |
Mark M. |
the ScrollView could cause problems with GestureDetector
|
Mark M. |
and I don't know if GestureDetector handles multitouch
|
Jumana A. |
oh is it?
|
Jumana A. |
ok
|
Mark M. |
you might need to create a PinchableTextView subclass of TextView and handle the touch events yourself
|
Mark M. |
there are a few ImageView implementations that offer pinch-to-zoom, which you could use as a basis
|
Jumana A. |
can i refer to them from somwhere?
|
Jumana A. |
do you know any references?
|
Mark M. |
not handy, sorry
|
Mark M. |
should be findable via a search engine
|
Jumana A. |
np
|
Jumana A. |
ok
|
Mark M. |
Bruce: do you have another question?
|
Bruce F. |
Yes, this may be more of a Google API question though.
|
Bruce F. |
View paste
|
Mark M. |
what API are you referring to?
|
Bruce F. |
The google image api was deprecated, I forget the name of the one as a replacement
|
Bruce F. |
Should have come here armed with the reference
|
Mark M. |
most likely, I haven't used it
|
Mark M. |
I don't use much in the way of Google APIs
|
Mark M. |
so I haven't a clue on pricing
|
Mark M. |
I'm not doing very well with your questions today... :-(
|
Mark M. |
Justin: are you still question-less?
|
May 1 | 10:25 AM |
Bruce F. |
So I could simply steer the user to google images, with using he api?
|
Mark M. |
Bruce: I have no idea
|
Mark M. |
Jumana: do you have another question?
|
Jumana A. |
yes...My app reads the quotes from an xml that I
have created. I want the user to be able to mark any of the displayed
quotes as his favorite so he can refer to them again. How do i best
implement that? Do i have to create something similar to a database?
(Please note Im a complete novice)
|
Mark M. |
a database would be a likely option
|
Mark M. |
you could edit the XML and add a "favorite" flag
there, but that becomes a problem if you want to replace the XML later
on with new/different quotes
|
Mark M. |
you could store the bookmark data in some other non-database file (XML, JSON, etc.)
|
Mark M. |
any persistent data store you like would work, though SharedPreferences' API is not well-suited for your case
|
Jumana A. |
which is better - storing in database or some non db file?
|
Mark M. |
that depends entirely on your personal criteria for "better"
|
Mark M. |
I cannot answer that in the abstract
|
Jumana A. |
faster i mean
|
Mark M. |
faster to run? faster to code? faster in some other way?
|
Jumana A. |
faster to run
|
Mark M. |
that too cannot be answered in the abstract
|
Mark M. |
it depends upon what you cache in memory, how you plan on accessing the data, etc.
|
May 1 | 10:30 AM |
Mark M. |
this has little to do with Android and everything to do with standard persistent data programming design
|
Jumana A. |
mark - this is silly - but i have to ask...by "database" you mean...??
|
Jumana A. |
with reference to your books?
|
Mark M. |
Android integrates SQLite, as is covered in _The Busy Coder's Guide to Android Development_
|
Jumana A. |
ok
|
Jumana A. |
not content providers right?
|
Mark M. |
ContentProvider is a facade over your choice of persistent data store, typically SQLite
|
Mark M. |
ContentProvider itself does not store anything
|
Jumana A. |
ah ...ok
|
Mark M. |
let me check with the others and I'll get back to you shortly
|
Mark M. |
Bruce: do you have another question, perhaps one I can answer? :-)
|
Jumana A. |
ya ok sure
|
Bruce F. |
I'll try, but it's related to my previous question.
|
Bruce F. |
Default behavior on android is that a long press
on an image in a webview downloads the image. I want to make use of
that image. Any ideas?
|
Justin M. |
I'm back now, when it's my turn again, I have a quick question, no rush
|
Mark M. |
hmmm... never tried that
|
Mark M. |
do you have any sense if WebView itself is downloading it?
|
Mark M. |
or is it launching a browser app, which is downloading it?
|
Bruce F. |
no, I don't know
|
Mark M. |
if WebView itself is downloading it, a WebViewClient might be informed of the event
|
Mark M. |
either onLoadResource() or shouldOverrideUrlLoading(), perhaps
|
Bruce F. |
thank you
|
May 1 | 10:35 AM |
Mark M. |
oh, there's also shouldInterceptRequest(), though that's new for API Level 11
|
Mark M. |
I'd see if any of those get control
|
Mark M. |
Justin: OK, fire away with your questino
|
Mark M. |
er, question
|
Mark M. |
OK, I'll try again later
|
Mark M. |
Jumana: do you have another question?
|
Jumana A. |
yes...
|
Jumana A. |
the quote of the day should be coming as
notification say once every day( or depending on the frequency the user
sets) instead of the user having to open the app everyday. How do i
implement that?
|
Mark M. |
use AlarmManager to schedule the daily event
|
Jumana A. |
ok
|
Mark M. |
that is covered in _The Busy Coder's Guide to
Advanced Android Development_, though more with an eye towards the
"check for new email every 15 minutes" scenario
|
May 1 | 10:40 AM |
Jumana A. |
oh ok
|
Jumana A. |
will refer to that
|
Mark M. |
Bruce: do you have another question?
|
Bruce F. |
not at the moment, thanks
|
Mark M. |
Justin: do you have another question?
|
Mark M. |
OK, if anyone has a question, chime in
|
Jumana A. |
Like i said, Im reading the quotes and related
details like author etc from an xml. And im using XML pull parser to
retrieve quotes. Is that the most efficient way of doing it?
|
Mark M. |
XmlPullParser, speed-wise, is roughly the same as SAX
|
Mark M. |
if you prefer the XmlPullParser API, feel free to use it
|
Jumana A. |
when i run the app, it takes a few seconds for the quote to be displayed, thats why the doubt
|
Mark M. |
how big is the XML file?
|
Jumana A. |
not much at all
|
Jumana A. |
30 kb
|
Mark M. |
that seems slower than I would expect
|
May 1 | 10:45 AM |
Mark M. |
you might consider using Traceview to determine exactly where your time is being taken up
|
Mark M. |
Traceview is covered in _Tuning Android Applications_
|
Jumana A. |
oh ok
|
Jumana A. |
oh great
|
Jumana A. |
will refer to that
|
Jumana A. |
is sqllite commonly used in apps for data storage?
|
Mark M. |
it's probably the most popular persistence mechanism
|
Jumana A. |
im considering moving all quotes and all its details into sqllite
|
Mark M. |
that's a possibility
|
Jumana A. |
instead of xml
|
Mark M. |
how are your quotes getting to the device?
|
Jumana A. |
as of now , xml
|
Mark M. |
no, that is how you are storing them
|
Mark M. |
how are they getting to the device?
|
Jumana A. |
(scratching my head) not sure what youre asking
|
Mark M. |
are you downloading them off the Internet? is the XML packaged in res/xml/ of the app? something else?
|
Jumana A. |
oh no it will be packaged with the app
|
Jumana A. |
under res/xml
|
Mark M. |
and you are using getResources().getXml() to load it?
|
Jumana A. |
yes
|
May 1 | 10:50 AM |
Mark M. |
hmmm... then I do not think the problem is in the XML parsing
|
Mark M. |
XML resources parse about ten times faster than plain XML files
|
Mark M. |
there is no way a 30KB XML resource is taking seconds to parse
|
Mark M. |
hence, I again recommend Traceview -- find out
where your problem really is, before optimizing things that may not need
optimizing
|
Jumana A. |
oh ok ...ill have a look at the trace then
|
Jumana A. |
if bruce and justin dont have any more questions, i would like to ask more pls
|
Bruce F. |
none from me.
|
Mark M. |
Bruce? Justin? any questions?
|
Justin M. |
Yes, I do, sorry I've been at the office, distracted
|
Justin M. |
Just one
|
Justin M. |
Might be in your books already and I missed it..
|
Justin M. |
What is the best way to use SQLiteDatabaseHelper
with a database with multiple tables? A lot of the examples I've seen
in the past only show how to get it to work with one table. Wondering
if you have examples of best practices or where I could look for more
info
|
Mark M. |
SQLiteOpenHelper is not dramatically different for more tables
|
Mark M. |
you would need to add more statements to onCreate() and onUpgrade()
|
Mark M. |
to set up/upgrade the other tables
|
Mark M. |
that's pretty much it
|
Mark M. |
am I missing something?
|
May 1 | 10:55 AM |
Justin M. |
No, it's probably me. I really don't have a
well-formed question about it... so I'll come back with something more
specific in future sessions. Thanks :-)
|
Mark M. |
OK
|
Mark M. |
Jumana: do you have another quick question?
|
Jumana A. |
yes ...mark, if im having a single table to store
quote nos, quote texts and whether favorite or not. ANd in future if i
need to add more quotes into the app, how is the data in the "favorite
or not" column maintained?
|
Jumana A. |
in other words, how is the user-related data maintained?
|
Mark M. |
if you are using SQLiteOpenHelper, you will be
given control if, when the user upgrades their app, Android detects that
your database table structure needs updating as well
|
Mark M. |
you would then execute the appropriate SQL statements (e.g., ALTER TABLE) to add any columns
|
Mark M. |
or INSERT statements to add more quotes
|
Mark M. |
or whatever
|
Jumana A. |
ohok great
|
Jumana A. |
thanks mark...will shoot more on thursday! :-)
|
Mark M. |
OK
|
May 1 | 11:00 AM |
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
next one is Thursday at 4pm Eastern
|
Bruce F. |
thanks
|
Bruce F. | has left the room |
Mark M. |
have a pleasant day, all!
|
Justin M. |
Thanks, take care
|
Jumana A. | has left the room |
Justin M. | has left the room |
Mark M. | turned off guest access |