Mark M. | has entered the room |
Mark M. | turned on guest access |
Jun 22 | 4:00 PM |
Guy | has entered the room |
EGHDK | has entered the room |
Mark M. |
hello, Guy!
|
Guy |
hello\
|
Mark M. |
how can I help you today?
|
Guy |
InputMethodService
|
Mark M. |
(and hello EGHDK -- Guy beat you by a couple of seconds!)
|
Mark M. |
Guy: I know of InputMethodService, though I haven't written one
|
Guy |
I need to make custom emoji IMAGE not unicode text with a keyboard
|
Mark M. |
um, few apps will know what to do with that
|
Guy |
how can I send an image by clicking the keyboard
|
Guy |
yes I knwo
|
Guy |
I need to build one
|
Mark M. |
then what is the point of doing it, if it will not work reliably?
|
Guy |
it is cliking the custom keyboard and sending an image
|
Guy |
cant share intent because it isnt an activity
|
Mark M. |
again, what is the point of writing a soft keyboard that will not work?
|
Guy |
a client wants one :(
|
Guy |
after researching I got to a dead end
|
Mark M. |
then you should find another client
|
Guy |
LOL.
|
Guy |
thanks anyway
|
Jun 22 | 4:05 PM |
Mark M. |
the InputConnectionMethods for supplying replacement text support a CharSequence
|
Mark M. |
you're welcome to try passing over a SpannedString that contains ImageSpan widgets
|
Mark M. |
but unless the app the user is using *specifically* is expecting that sort of thing, the image will be ignored by the app
|
Mark M. |
making the whole exercise pointless
|
Guy |
I understand
|
Mark M. |
and I do not know enough about InputMethodEditor to know when commitText() and setComposingText() get used
|
Mark M. |
I apologize for not being of greater assistance to you
|
Mark M. |
let me take a question from EGHDK, and I will be back with you in a bit
|
Mark M. |
EGHDK: your turn! do you have a question?
|
Guy |
just wanted to make sure. thanks again :)
|
EGHDK |
Yeah mark. More of a java-ish question. Is there any way to make sure that someone has to override a method AND call the super implementation?
|
Mark M. |
not through Java syntax
|
Guy | has left the room |
EGHDK |
I think at io, they announced an annotation for it. but I don't really know too much about annotations.
|
Mark M. |
that's a possibility, though I haven't paid too much attention to those custom annotations
|
Mark M. |
in the case of methods like `onPause()`, where if you fail to chain to the superclass you get a `SuperNotCalledException`, they are presumably using some flag
|
Mark M. |
so they have some boolean wasSuperCalled=false, set that to true in the super's onPause(), and check wasSuperCalled after calling your onPause()
|
Jun 22 | 4:10 PM |
Mark M. |
if it is still false, you did not chain to the superclass, and so they throw the exception
|
EGHDK |
gotcha. thats very helpful. thanks.
|
EGHDK |
I'm sure I could look through your changelog... but have you made any book additions for io? anything regarding gcm?
|
Mark M. |
not recently
|
Mark M. |
other than to say "I
|
Mark M. |
er
|
Mark M. |
other than to say "I am not maintaining this chapter much"
|
Mark M. |
I do need to either get it caught up with GCM 3.0 or nuke the chapter outright
|
EGHDK |
gotcha. seems like they basically fixed gcm. no more of those workarounds people had to use.
|
Jun 22 | 4:15 PM |
Mark M. |
you have boundless optimism :-)
|
EGHDK |
hahaha
|
EGHDK |
so a question about singleton. I was reading the design patterns book and in a bullet point they say "be careful if you are using multiple class loaders; this could defeat the Singleton implementation and result in multiple instances"
|
EGHDK |
I don't understand that sentence, and was wondering if it makes any sense to you
|
Mark M. |
oh, yes, it makes sense
|
Mark M. |
fortunately, 95% of the time, we don't worry about classloaders in Android
|
Mark M. |
what specifically would you like to know?
|
EGHDK |
I guess... what a class loader is?
|
Mark M. |
as the name suggests, it loads classes
|
EGHDK |
Is that just the moment when it loads a class?
|
EGHDK |
But isn't a constructor a loader?
|
Mark M. |
no
|
Mark M. |
a classloader is responsible for reading in a class definition (e.g., out of a JAR file in a classic desktop/server Java environment)
|
Mark M. |
and creating the corresponding Class object, and otherwise making the class available for use
|
Jun 22 | 4:20 PM |
EGHDK |
Hm. guess I'll look into it a bit more, because that doesn't seem to make too much sense to me.
|
Mark M. |
let's draw an analogy
|
Mark M. |
you're using a Web browser right now
|
Mark M. |
the Web page that we are doing this chat in probably has some JavaScript in it
|
Mark M. |
that JavaScript lives in a file on a server
|
Mark M. |
the only reason why the JavaScript is executing in your browser is because something did the HTTP request to load it, then set it up in a JavaScript interpreter/runtime environment
|
Mark M. |
without that "script loader", the JavaScript would sit on the server, forever lonely and unused
|
Mark M. |
a classloader in Java fills the same sort of role, minus the network I/O, for loading in Java classes to the runtime environment
|
EGHDK |
Hm. So you said you really don't encounter them in android, so it's probably not a big deal to worry about. Again, I'm just unsure of how often a class loader is used. Is a class loader used every time you "load" a class? So anytime you reference it, or create an object of it?
|
Jun 22 | 4:25 PM |
Mark M. |
"you really don't encounter them in android" -- no, I said you don't really *worry* about them in Android
|
Mark M. |
"Is a class loader used every time you "load" a class? So anytime you reference it, or create an object of it?" -- yes
|
Mark M. |
classically, with Dalvik, Java classes would not be loaded until referenced
|
Mark M. |
now, with ART, I don't really know where and how the classloader concept comes into play
|
MiguelFebres | has entered the room |
Mark M. |
hello, Miguel!
|
MiguelFebres |
Hello Everyone
|
EGHDK |
Thanks. Thats helpful. So it's just when it gets loaded. Maybe I was overthinking it.
|
MiguelFebres |
Hello Mark, I just subscribed to the CommonsWare program so I am new here
|
Mark M. |
EGHDK: let me take a question from Miguel, and I'll be back with you in a bit
|
Mark M. |
Miguel: thanks for subscribing! how can I help you today?
|
MiguelFebres |
Thanks Mark
|
MiguelFebres |
I developed a streaming client application in android using a service
|
MiguelFebres |
all works as expected but, I have the problem that as soon the activity is destroyed, my service stops
|
MiguelFebres |
I read about startservice vs bindservice but still my service stops
|
MiguelFebres |
and this is hard to test because it could happen after 5 minutes or after 1 hour
|
Jun 22 | 4:30 PM |
MiguelFebres |
so its randomly
|
Mark M. |
well, services don't live forever
|
Mark M. |
that's why most media players use a foreground service, as they are part of the foreground user experience
|
MiguelFebres |
ok but I am a heavy spotify user and I spotify almost never stops to stream
|
Mark M. |
does Spotify have an icon in the status bar, from a Notification?
|
MiguelFebres |
I would like to make my service last forever as Spotify
|
MiguelFebres |
yes, and actually have some buttons in the notification there like play, next
|
Mark M. |
they are using a foreground service, most likely
|
MiguelFebres |
ok so would you say I should use a foreround service for my purpose?
|
MiguelFebres |
*foreground service
|
Mark M. |
again, most media players use a foreground service
|
Mark M. |
there is a section on foreground services in the chapter on Notifications in the book, as you need a Notification to have a foreground service
|
Mark M. |
see page 758 of Version 6.7 of the book
|
Mark M. |
ideally, your Notification provides the same sorts of media controls as you see Spotify and other media players offer in their notifications
|
Mark M. |
let me take another question from EGHDK, and I will be back with you shortly
|
MiguelFebres |
ok I will read about that in the book and see if I can make it work... May I ask you another related question?
|
MiguelFebres |
ok
|
Mark M. |
EGHDK: do you have another question?
|
Jun 22 | 4:35 PM |
Mark M. |
EGHDK: if you come up with another question, ping me here on the chat so I can give you a turn
|
Mark M. |
Miguel: back to you!
|
MiguelFebres |
ok I am reading about that in the pdf but I would like to know something else
|
Mark M. |
Miguel: go ahead
|
MiguelFebres |
another issue I have with my current application is that if the application is running and streaming the music and someone call to the phone, the service stops/pause (no sure what happens exactly) and the phone rings
|
MiguelFebres |
if the user does not answer and just ignore the call, the music from my application continue
|
MiguelFebres |
so no problem
|
MiguelFebres |
but if the person answer the call
|
MiguelFebres |
and finish the call
|
MiguelFebres |
he must go to my application by hand and press play to resume
|
MiguelFebres |
I tested with Spotify, and the music continue after I finish the incoming call
|
MiguelFebres |
how I can do the same with my service?
|
Mark M. |
well, first, please consider the length of the call in your plans
|
Jun 22 | 4:40 PM |
Mark M. |
automatically resuming playback after a short call seems fine
|
Mark M. |
automatically resuming playback after a longer call is risky
|
Mark M. |
as the environment around the user may have changed
|
Mark M. |
and it may not be appropriate to play back music at that point
|
Mark M. |
particularly when it might be through a phone speaker, versus a headset or something
|
Mark M. |
that being said, you will want to look at the audio focus APIs: http://developer.android.com/training/managing-...
|
MiguelFebres |
so that is actually that Android OS decide or I must configure my service to handle that situation?
|
Mark M. |
a little of both
|
MiguelFebres |
ok I will take a look on that link after reading the pdf
|
Mark M. | |
Mark M. |
I have not used these APIs, so other than I know this is the right area, I do not know the details of how best to handle your case
|
Mark M. |
if either of you has a question, go right ahead
|
MiguelFebres |
ok thanks
|
MiguelFebres |
how long you will be here?
|
Mark M. |
the chat runs for another ~15 minutes
|
Jun 22 | 4:45 PM |
Mark M. |
they run an hour each
|
Jun 22 | 4:50 PM |
EGHDK | has left the room |
Jun 22 | 4:55 PM |
MiguelFebres |
Mark, when is the next chat available?
|
Mark M. |
the next one is 9am US Eastern tomorrow
|
Mark M. |
the calendar for the chats is on the Warescription site (https://wares.commonsware.com)
|
MiguelFebres |
ok I see, it is in the calendar
|
MiguelFebres |
ok
|
Mark M. |
usually, they are Tuesdays and Thursdays
|
Mark M. |
it varies somewhat based on my travel schedule
|
MiguelFebres |
Mark! Now it works!
|
MiguelFebres |
I kill my activity and the streaming continues!
|
MiguelFebres |
but even with a Foreground Service, Android OS can kill the service any moment right?
|
Mark M. |
yes, though a foreground service is usually pretty durable
|
Jun 22 | 5:00 PM |
Mark M. |
it will depend on how much system RAM there is on the device
|
Mark M. |
but a foreground service can often run for days
|
Mark M. |
which probably is longer than you need it
|
MiguelFebres |
ok great! that is what I was looking for
|
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
MiguelFebres |
thanks Mark, I will be back tomorrow for more questions
|
MiguelFebres |
thanks
|
Mark M. |
sounds good
|
Mark M. |
have a pleasant day!
|
MiguelFebres |
you too
|
MiguelFebres | has left the room |
Mark M. | turned off guest access |