Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 12 | 3:55 PM |
Dimitris K. | has entered the room |
Mark M. |
hello, Dimitris!
|
Mark M. |
how can I help you today?
|
Sep 12 | 4:00 PM |
Dimitris K. |
Hey Mark !
|
Dimitris K. |
So I have a service and in that service im running a thread that is constantly waiting to receive data
|
Dimitris K. |
the data is coming from a barcode scanner that is build it the device
|
Dimitris K. |
the device is an android tablet running API 19
|
Dimitris K. |
when the device goes to sleep mode I keep the service alive
|
Dimitris K. |
but the thread seems to stop running
|
Dimitris K. |
(the service is foreground with a notification)
|
Mark M. |
are you using a partial wakelock to prevent the device from going to sleep?
|
Dimitris K. |
im trying to use one
|
Dimitris K. |
View paste
|
Dimitris K. |
this should be enough right ?
|
Mark M. |
assuming that you hold the WAKE_LOCK permission, that should be fine
|
Dimitris K. |
yep I do
|
Mark M. |
OK, what are your specific symptoms that lead you to believe that the thread is not running?
|
Dimitris K. |
well im logging something in the thread so I get constant logs as long as its running and when I press the power button it stops
|
Sep 12 | 4:05 PM |
Mark M. |
logging to LogCat?
|
Dimitris K. |
yes
|
Mark M. |
and you're getting other LogCat messages after the power button, just not yours?
|
Dimitris K. |
ok good question I think im not getting any afterwards
|
Mark M. |
usually, devices are fairly chatty on LogCat, so if you're getting *nothing* after pressing the power button, either LogCat itself is not reporting anything, or the device is going to sleep mode despite the wakelock
|
Mark M. |
it's possible that your device just doesn't log all that much, in which case this isn't a good test
|
Mark M. |
but I'd try to determine for certain whether the no-LogCat issue is unique to your app or is device-wide
|
Dimitris K. |
I will confirm this now
|
Dimitris K. |
regarding the thread itself
|
Sep 12 | 4:10 PM |
Dimitris K. |
I continue getting normal logs
|
Dimitris K. |
but not from my thread anymore
|
Mark M. |
OK, so this appears to be unique to your app
|
Dimitris K. |
yes
|
Dimitris K. | |
Dimitris K. |
this is how I start the thread
|
Mark M. |
next question: is this thread polling on something? or what is this thread really doing that is allowing you to both get data from the barcode scanner *and* log messages?
|
Dimitris K. |
I will paste it just give me a second
|
Dimitris K. |
there is no secret so here it is
|
Dimitris K. |
View paste
(22 more lines)
|
Sep 12 | 4:15 PM |
Mark M. |
you might want to add a lot more Log.e() calls in there, to see where things get stuck
|
Mark M. |
for example, perhaps read() does not time out after you have pressed the power button
|
Dimitris K. |
hmmm
|
Dimitris K. |
this actually might be the issue
|
Raghavendra M. | has entered the room |
Raghavendra M. |
Hi mark
|
Dimitris K. |
I will get back to you after testing a bit more Mark
|
Mark M. |
Dmitris: OK, sounds good
|
Mark M. |
Raghavendra: hi! it's your turn -- do you have a question?
|
Raghavendra M. |
Hi mark i am raghu
|
Raghavendra M. |
yes
|
Raghavendra M. |
i am trying a design a time bar
|
Raghavendra M. | |
Raghavendra M. |
uploaded a screenshot
|
Raghavendra M. |
its basically for room booking
|
Raghavendra M. |
how would i start doing it
|
Raghavendra M. |
seek bar
|
Mark M. |
is the orange dot something that the user slides?
|
Raghavendra M. |
yeah he can select time
|
Raghavendra M. |
while booking
|
Sep 12 | 4:20 PM |
Raghavendra M. |
its like a range bar
|
Mark M. |
OK, then a SeekBar, or something derived from a SeekBar, is probably the starting point
|
Mark M. |
there are quite a few of these things on the Android Arsenal
|
Raghavendra M. |
yeah i have add a look
|
Mark M. | |
Raghavendra M. |
but its tough to create labels on seek bar and range bar
|
Raghavendra M. |
with 15 min steps
|
Mark M. |
unless your time range is fairly small, you won't have screen space for 15-minute labels
|
Raghavendra M. |
yeah
|
Mark M. |
personally, I would label the ends and show the currently-selected value
|
Raghavendra M. |
ok
|
Mark M. |
and use a discrete bar (there are a few on the Arsenal) for limiting the user to your 15-minute intervals
|
Raghavendra M. |
how would i color them based on booking
|
Raghavendra M. |
green for available
|
Raghavendra M. |
red for booked
|
Mark M. |
um, probably not easily :-)
|
Raghavendra M. |
yeah
|
Mark M. |
ideally, you colorize the bar itself (versus having some background image behind it that you're hoping will line up)
|
Mark M. |
that might require modifications to the discrete bar implementations
|
Mark M. |
I haven't looked at them in depth
|
Raghavendra M. |
ok
|
Raghavendra M. |
thanks for the suggestion mark
|
Mark M. |
those that are implemented as a true custom View will have an onDraw() method where they render the bar
|
Mark M. |
and that would need to be adjusted to paint in different colors for different segments or something
|
Raghavendra M. |
it requires a whole new component design
|
Sep 12 | 4:25 PM |
Mark M. |
possibly
|
Raghavendra M. |
with rectangular areas
|
Mark M. |
in which case, you are using the existing discrete bars as an inspiration for your own custom view
|
Raghavendra M. |
ok
|
Mark M. |
you would need to survey the existing libraries to see whether extending SeekBar is the right answer or not
|
Raghavendra M. |
yeah
|
Mark M. |
my guess is that some do and some do not
|
Mark M. |
in the latter case, they handle the touch events themselves
|
Raghavendra M. |
ohh
|
Raghavendra M. |
big challenge is colorring
|
Raghavendra M. |
rest is acheivable
|
Mark M. |
well, given that you know the overall range, and you have a list of ranges/colors to apply, it's mostly a matter of converting time units to pixels
|
Mark M. |
and then drawing the right color over the right area
|
Mark M. |
bearing in mind that you probably need to change colors *between* the discrete seek positions, as you don't want the user to wonder what it means when 11:15 is red on the left and green on the right
|
Raghavendra M. |
yes
|
Mark M. |
you would want the color change to be at 11:22 or thereabouts
|
Mark M. |
so each discrete seek position has a single color associated with it
|
Mark M. |
it's an interesting problem
|
Raghavendra M. |
yeah
|
Raghavendra M. |
there is no solution in git or arsenal
|
Raghavendra M. |
which is close
|
Raghavendra M. |
only to design the component
|
Mark M. |
then use them as inspiration, and start from scratch (more or less)
|
Sep 12 | 4:30 PM |
Raghavendra M. |
ok
|
Mark M. |
let me take another question from Dimitris, and I'll return to you shortly
|
Mark M. |
Dimitris: your turn! do you have another question?
|
Dimitris K. |
So mark my thread is killed
|
Dimitris K. |
after pressing the power button there are no more logs from it
|
Mark M. |
and you're sure that you're not indefinitely blocking on something?
|
Dimitris K. |
the only thing I didnt try is having a log before my while condition
|
Dimitris K. |
while (!Thread.currentThread().isInterrupted()) {
|
Mark M. |
I thought that would have occurred before you pressed the power button
|
Mark M. |
and that the power button press would be during the while loop
|
Dimitris K. |
should I overide the interrupted method in the thread
|
Dimitris K. |
and see if that is called ?
|
Mark M. |
I have never done that, so I don't know what to expect
|
Dimitris K. |
what about any known edge cases that can stop a thread from running
|
Dimitris K. |
is there something like that ?
|
Mark M. |
AFAIK, anything should result in a stack trace somewhere
|
Sep 12 | 4:35 PM |
Dimitris K. |
:/
|
Mark M. |
you might want to create a scrap project that you can use to experiment with this
|
Mark M. |
create a service, with a wakelock, with a thread, but drop the serial port I/O
|
Mark M. |
do your polling-style loop, just without any actual polling of anything, only Thread.sleep(2)
|
Mark M. |
(though I'd use SystemClock.sleep() on Android)
|
Mark M. |
and see if you get log messages
|
Mark M. |
after the power button is pressed
|
Dimitris K. |
ok that makes sense
|
Dimitris K. |
and if not ?
|
Mark M. |
if the answer is no, then your wakelock is being ignored, and I don't know why
|
Mark M. |
if the answer is yes, then I'm back to believing that you are blocking on the serial I/O
|
Dimitris K. |
is there any alternative ?
|
Dimitris K. |
of a thread
|
Mark M. |
in either case, it probably involves discussions with the device manufacturer
|
Mark M. |
I have no idea of what the expected behavior is here
|
Mark M. |
for all I know, this is just how their hardware works
|
Mark M. |
but, I would do the analysis to try to narrow the problem down as far as possible before trying to talk to the manufacturer
|
Dimitris K. |
should I also try it with a ThreadPoolExecutor
|
Dimitris K. |
can it make any dif?
|
Mark M. |
I don't see how that can work in your case
|
Mark M. |
but, if you see a path to it, you're welcome to give it a try
|
Mark M. |
I doubt that it will change matters, though
|
Sep 12 | 4:40 PM |
Dimitris K. |
ok Mark thank you it seems that at least what I was trying so far is not wrong so I just have to research it further
|
Mark M. |
well, it's "not wrong" in that I would not expect your symptoms
|
Mark M. |
whether this is a good pattern for serial I/O on Android is outside my area of expertise
|
Mark M. |
and I have no idea whether this is a good pattern with this particular piece of hardware
|
Dimitris K. |
same goes for me :/
|
Mark M. |
let me switch back to Raghavendra for a bit, and I'll try to get back to you before the chat ends
|
Mark M. |
Raghavendra: your turn! do you have another question?
|
Raghavendra M. |
last question is is there any other alternative
|
Raghavendra M. |
where we can select a time range
|
Raghavendra M. |
or a component
|
Mark M. |
there is nothing built into Android for it, if that is what you mean
|
Mark M. |
other than TimePicker
|
Raghavendra M. |
ok
|
Mark M. |
and that *really* does not fit your custom coloring plan
|
Raghavendra M. |
yeah
|
Raghavendra M. |
will try it
|
Raghavendra M. |
thanks mark
|
Mark M. |
you're welcome!
|
Mark M. |
OK, if either of you have any questions, chime in, for the balance of the chat
|
Dimitris K. |
not yet probably I will be back on your next office hour
|
Sep 12 | 4:45 PM |
Dimitris K. |
with proper investigation data
|
Mark M. |
that will be Thursday, at 7:30pm US Eastern
|
Dimitris K. |
that will be tough for me :D
|
Mark M. |
the one after that is Saturday at 9am US Eastern -- friendlier time, less-friendly day
|
Raghavendra M. |
sure will chat on thurday
|
Dimitris K. |
friendlier time is enough for me :D
|
Raghavendra M. | has left the room |
Sep 12 | 4:50 PM |
Dimitris K. |
have a nice day Mark
|
Mark M. |
you too!
|
Dimitris K. | has left the room |
Sep 12 | 4:55 PM |
Mark M. | turned off guest access |