Feb 3 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Feb 3 | 9:20 AM |
Bart | has entered the room |
Bart |
Hello
|
Mark M. |
hello, Bart!
|
Mark M. |
(wish this chat would signal when people enter the room...)
|
Mark M. |
how can I help you today?
|
Bart |
first off, i'm a total beginner when it comes to android and your book has been very useful :)
|
Mark M. |
glad that it's helping!
|
Feb 3 | 9:25 AM |
Bart |
i'm following the tutorials and i'm kinda stuck at the end of chapter 14
|
Mark M. |
do you mean Tutorial 14?
|
Bart |
i think the editor fragment is taking up all the space; the action bar is not showing
|
Bart |
ah yes, tutorial 14
|
Mark M. |
well, the action bar, in terms of whether it exists or not, is driven by the activity
|
Mark M. |
if your activity element in the manifest looks like <activity android:name="NoteActivity"></activity>, then the action bar should show up just fine
|
Mark M. |
could you take a screenshot of your device/emulator, then upload it into the chat (there is an "Upload a file" link on the right)
|
Yaniv S. | has entered the room |
Mark M. |
hello, Yaniv!
|
Feb 3 | 9:30 AM |
Mark M. |
Bart: let me take a question from Yaniv, while you get the screenshot, and I will come back to you in a bit
|
Yaniv S. |
Hello!
|
Mark M. |
Yaniv: your turn! do you have a question?
|
Bart |
alright
|
Yaniv S. | |
Yaniv S. |
I have an android based device which has serial (RS232) connection
|
Yaniv S. |
View paste
|
Yaniv S. |
2. receives and transmits data through the network
|
Mark M. |
the Android SDK has no specific support for serial connections
|
Yaniv S. |
3. receives GPS data
|
Yaniv S. |
I know.
|
Mark M. |
you would have to ask your device manufacturer what the programming model is for that
|
Yaniv S. |
I gathered special API's which I found online and managed to do so
|
Yaniv S. |
my question is this :
|
Yaniv S. |
when I create the service , in the onStartCommand , can I run multiple threads ? where each thread manages different connection?
|
Bart |
Mark, to be clear, you want me to take a screenshot on my phone (im testing on my device)? because there's not much to see; everything's white
|
Mark M. |
sure
|
Bart | |
Mark M. |
Bart: that is what I wanted to see -- I'll be back with you on it in a bit
|
Feb 3 | 9:35 AM |
Mark M. |
Yaniv: you are welcome to fork threads, either individually or via some manager (e.g., ThreadPoolExecutor)
|
Mark M. |
you will be responsible for shutting down those threads when they are no longer needed
|
Mark M. |
and, in particular, not leaking those threads when the service is destroyed
|
Bart |
alright
|
Mark M. |
Yaniv: whether the special APIs from your manufacturer support multi-threaded access, I cannot say
|
Yaniv S. |
my intention is that this service will automatically start on BOOT and restart if destroyed
|
Yaniv S. |
ok thanks. another question :
|
Yaniv S. |
lets say my service is up and running on the device
|
Mark M. |
Yaniv: let me follow-up with Bart first, then I will come back to you
|
Yaniv S. |
ok .
|
Mark M. |
Bart: somebody definitely ate your action bar
|
Mark M. |
I'm not quite sure how this is happening
|
Mark M. |
have you compared your code with the "answers" up at the GitHub repo?
|
Bart |
i can pastebin relevant parts of the code if you want
|
Bart |
yes
|
Bart |
but maybe not good enough
|
Mark M. |
the action bar is showing up on the main EmPubLiteActivity correctly?
|
Bart |
yes, with the "edit note" icon
|
Bart |
and it just disappears when i press that
|
Mark M. |
if you could pastebin your NoteActivity and your manifest, that might give me some clues
|
Mark M. |
another thing you can always do is download and run the "answers" for Tutorial 14
|
Feb 3 | 9:40 AM |
Mark M. |
if that gives you the same result, then either there's some bug in the tutorial that you're tripping over that I haven't seen, or there's something funky with your test environment
|
Bart |
ok let me do that first
|
Mark M. |
if, OTOH, the project in GitHub works as the tutorial instructions state, then we know that the issue lies somewhere in your project
|
Mark M. |
I'll take Yaniv's next question and will come back to you in a bit
|
Mark M. |
Yaniv: OK, go ahead with your next question
|
Yaniv S. |
View paste
|
Yaniv S. |
how do I do that if I have no activity? how do I pop up my own custom dialog to the user ?
|
Mark M. |
you need an activity
|
Mark M. |
it could be a dialog-themed activity, so it looks like a dialog
|
Feb 3 | 9:45 AM |
Yaniv S. |
oh.. ok
|
Mark M. |
bear in mind that the user may not necessarily appreciate a dialog popping up in the middle of whatever the user is doing
|
Mark M. |
it is possible that your proposed UI flow is appropriate for your use case
|
Mark M. |
however, in general mobile development, there are few places where background operations should interrupt the user
|
Yaniv S. |
yes this is what I want . but I also want that whenever a message from the service received, the dialog pops up on top of the previous dialog if there was already was one.
|
Mark M. |
that is rather user-hostile
|
Yaniv S. |
can this be acheived ?
|
Mark M. |
a better UX would be to update the existing dialog to reflect any new information
|
Yaniv S. |
oh..yes that better
|
Yaniv S. |
update :)
|
Yaniv S. |
so how can this be done ?
|
Mark M. |
I'd use an event bus (e.g., greenrobot's EventBus)
|
Bart |
ok, your github version works. I'm gonna compare it to my version now :)
|
Mark M. |
when the conditions occur when the dialog is needed, the service raises an event on the bus saying "hey, update the UI!"
|
Mark M. |
if the service determines that nobody picked up that message, that would indicate that you do not have a UI at the moment, and the service launches the dialog-themed activity
|
Feb 3 | 9:50 AM |
Mark M. |
Bart: OK -- I'd focus on what's in NoteActivity and your manifest
|
Mark M. |
Yaniv: you can see that sort of pattern in samples like https://github.com/commonsguy/cw-omnibus/tree/m... from my book
|
Yaniv S. |
sounds like exactly what I need , where can I read how to do that?
|
Mark M. |
in that case, I either update the existing UI or raise a Notification, as that would be more common in mobile devices
|
Mark M. |
in your case, you would replace the raise-the-Notification stuff with starting your activity
|
Mark M. |
I have a chapter in the book on event buses which walks through that example, plus equivalent examples using LocalBroadcastManager and Square's Otto (two other event bus implementations)
|
Yaniv S. |
which chapter in your book discussed this?
|
Yaniv S. |
(wow you are a fast typer)
|
Mark M. |
"Event Buses Alternatives"
|
Mark M. |
(which is a really ugly chapter title, now that I think about it...)
|
Mark M. |
page 1591 of the Version 6.4 PDF
|
Yaniv S. | |
Mark M. |
Bart: if you encounter anything of note or have a question on your comparison, chime in
|
Mark M. |
Yaniv: go ahead, though the chat hour is nearly over, so make it fast :-)
|
Feb 3 | 9:55 AM |
Yaniv S. |
ok .
|
Yaniv S. |
so let's say I have the service running in the device's background
|
Yaniv S. |
and it receives information through the serial connection in the service
|
Yaniv S. |
now lets say I have different applications which I will write
|
Yaniv S. |
UI applications
|
Yaniv S. |
and these apps will use the information received from the service (which is a different app)
|
Yaniv S. |
how can I communicate and pass that info?
|
Mark M. |
:: shrug ::
|
Mark M. |
it would depend upon the nature of "that info"
|
Yaniv S. |
each message contains two int's and a string
|
Mark M. |
and how "these apps will use the information"
|
Mark M. |
if these are events, consider using broadcast Intents
|
Mark M. |
if these are pulled from the clients, rather than pushed via the service, you could use a service with AIDL (ick) or a ContentProvider
|
Yaniv S. |
yes, they are pulled from clients
|
Yaniv S. |
So either AIDL or content provider will work
|
Mark M. |
meaning that the clients are polling the service for updates?
|
Yaniv S. |
?
|
Bart |
Mark, I've literally copy+pasted your manifest and noteactivity code and no actionbar so far
|
Bart |
but i guess i'll narrow it down eventually
|
Bart |
thanks, maybe next time I'll have more interesting questions :p
|
Mark M. |
Bart: I would not expect the fragment itself to have an impact, but NoteFragment would be the next place to experiment
|
Feb 3 | 10:00 AM |
Yaniv S. |
yes , well, the information is supposed to be concealed basically but I need different apps (which I will write) to be able to use that information
|
Yaniv S. |
I hope it's not too confusing
|
Mark M. |
Yaniv: if this is event-driven, focus on broadcast Intents or maybe a ContentProvider (so you can leverage ContentObserver)
|
Yaniv S. | |
Yaniv S. |
info
|
Mark M. |
if this is purely on-demand from the client, you would need to use service binding or a ContentProvider
|
Yaniv S. |
yes Iv'e read about service binding and Content provider but coudn't decide which will work for me
|
Mark M. |
well, either could, in all likelihood
|
Yaniv S. |
you say they will both work for my purposes?
|
Mark M. |
again, it depends a lot upon the nature of the apps and the communications
|
Mark M. |
which is well outside the scope of one of these chats
|
Mark M. |
particularly one that ended a couple of minutes ago :-)
|
Mark M. |
that's a wrap for today's chat
|
Yaniv S. |
is this chat saved
|
Yaniv S. |
?
|
Mark M. |
the transcript will be posted to http://commonsware.com/office-hours/ shortly
|
Yaniv S. |
thanks !!
|
Yaniv S. |
you helped me alot
|
Mark M. |
the next chat is Thursday, 4pm US Eastern
|
Mark M. |
have a pleasant day!
|
Bart |
likewise
|
Yaniv S. |
ty
|
Bart | has left the room |
Yaniv S. | has left the room |
Mark M. | turned off guest access |