Apr 24 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Apr 24 | 9:00 AM |
wuqiang | has entered the room |
Mark M. |
hello, wuqiang!
|
Mark M. |
how can I help you today?
|
wuqiang |
long time no see
|
wuqiang |
hello
|
Mark M. |
do you have a question?
|
wuqiang |
today i have a question
|
Apr 24 | 9:05 AM |
ivano_ndrocchietto | has entered the room |
Mark M. |
wuqiang: please go ahead with your question
|
wuqiang |
some app like kind of chat app needs start along with system,and do some initialization
|
Mark M. |
(ivano: I will be with you shortly!)
|
Mark M. |
wuqiang: I am sorry... was that your question?
|
wuqiang |
i'm uploading a photo
|
wuqiang | |
Mark M. |
it works much better if you copy and paste text
|
Apr 24 | 9:10 AM |
Mark M. |
so, it looks like you may be using my WakefulIntentService, since I see a doWakefulWork() method
|
wuqiang |
yes
|
Mark M. |
however, you appear to be doing asynchronous work, as you are registering a listener
|
wuqiang |
it works ....
|
Mark M. |
perhaps in testing, but it may not be reliable
|
Mark M. |
once onHandleIntent() of an IntentService ends (or doWakefulWork() in this case), the service stops itself
|
wuqiang |
so ,this is my question
|
Mark M. |
your process can be terminated shortly afterwards
|
wuqiang |
like this situation do u have another solution ?
|
Mark M. |
if you want to do asynchronous work in a Service, use a regular Service, not IntentService or WakefulIntentService
|
Mark M. |
when the asynchronous work is done, call stopSelf() to destroy the Service
|
Apr 24 | 9:15 AM |
Mark M. |
wuqiang: let me take a question from ivano, and I will return to you shortly to continue this discussion
|
Mark M. |
ivano: your turn! do you have a question?
|
wuqiang |
the part i'm embedded in you "doWakefulWork" need to work within whole my app
|
ivano_ndrocchietto |
View paste
|
wuqiang |
ok
|
Mark M. |
"do you know which way should I proceed?" -- with respect to what?
|
Mark M. |
I have not tried directly replacing loaders with RxJava
|
ivano_ndrocchietto |
right. to meet the current best practice
|
Mark M. |
I am far from expert on RxJava; I cannot tell you what the best practices are
|
ivano_ndrocchietto |
if I well recall the CursorLoader API exploits an AsyncTask, that today is less desuete that populism
|
ivano_ndrocchietto |
OK thank you anyway to consider my question
|
Mark M. |
while I am not a fan of the Loader framework in general, there is nothing really wrong with CursorLoader itself AFAIK
|
Mark M. |
I am skeptical that you can wrap RxJava in the Loader API, though I cannot rule that out
|
Apr 24 | 9:20 AM |
Mark M. |
so, I would approach this less as "how do I replace CursorLoader with RxJava" as "how do I implement RxJava", where your use case happens to be loading data
|
ivano_ndrocchietto |
true. just need to stand to my future employee
|
Mark M. |
I have a chapter on Rx basics in the book
|
ivano_ndrocchietto |
I know
|
Mark M. |
that material covers two of the three Loader features: asynchronous work and data retention across configuration changes
|
ivano_ndrocchietto |
but querying a DB with a ThreadPool and RXJava is not trivial
|
ivano_ndrocchietto |
what is the third then?
|
Mark M. |
um, it should be
|
Mark M. |
(other than the ThreadPool part, perhaps)
|
Mark M. |
the third is the automatic delivery of fresh data
|
Mark M. |
which can
|
Mark M. |
which can't really be done other than for ContentProvider via ContentObserver
|
Mark M. |
or for your own internal stuff via an event bus
|
ivano_ndrocchietto |
Interesting building block to start to architecture
|
Mark M. |
that feature is the one that breaks the Loader approach for most use cases
|
ivano_ndrocchietto |
So ContentProvider is an Android Component that I have to maintain
|
Mark M. |
only if you want to have one
|
ivano_ndrocchietto |
after all is just a facade pattern
|
Mark M. |
I use them for inter-process data exchange
|
Mark M. |
purely within a process, they are more headache than they are worth IMHO
|
ivano_ndrocchietto |
between apps or do you mean Client Server?
|
Mark M. |
inter-process = between apps
|
ivano_ndrocchietto |
I see thanks
|
Mark M. |
with respect to database I/O, I expect that there are several libraries for reactive SQLite
|
Mark M. |
whether in the form of an ORM or something lighter-weight
|
Apr 24 | 9:25 AM |
Mark M. |
let me switch back to wuqiang for a bit, and I will return to you later on
|
Mark M. |
wuqiang: your turn! do you have another question?
|
wuqiang |
in fact i need a almot totally same scheme to your GreenRobot3
|
Mark M. |
well, greenrobot's EventBus is not mine, in that I did not write it
|
wuqiang |
i mean your demo program
|
Mark M. |
which one? I use greenrobot's EventBus in lots of sample apps
|
wuqiang |
in chapter Evevt Bus Alternative
|
Mark M. |
OK, so you are referring to the sample app where I use AlarmManager to raise events, delivering them to the UI via EventBus, or raising a Notification if the UI is not visible
|
Apr 24 | 9:30 AM |
wuqiang |
yes
|
wuqiang |
selt start ,register a listener ,if there a Activity display the message,if there no Activity make a Notification
|
wuqiang |
but it via a listener
|
wuqiang |
I’m in your “doWakefulWork” register a listener for “wilddog” (it is totally compatible with FireBase)
|
Mark M. |
again, a WakefulIntentService is not a good choice for this scenario
|
wuqiang |
how could i do with my idea
|
wuqiang |
the , what should i do ?
|
Mark M. |
well, I doubt that you want to do that, as your users will be *very* upset with yo
|
Mark M. |
er, upset with you
|
Mark M. |
what you are proposing is that the user's device has to be powered on *all the time*
|
Mark M. |
this will result in very short battery life
|
Mark M. |
that is why in Android 6.0+, Google added Doze mode and app standby
|
wuqiang |
it's so bad ...
|
ivano_ndrocchietto |
( indeed)
|
Mark M. |
those are there specifically because developers try doing things like this: having some service running all the time, keeping the device on, trying to do work
|
Mark M. |
since you have indicated that you are using Firebase, switch to Firebase Cloud Messaging
|
Mark M. |
use FCM to deliver chat updates to the devices
|
wuqiang |
i can't use it , in china ....
|
Mark M. |
then you cannot be using Firebase in general, AFAIK
|
Apr 24 | 9:35 AM |
Mark M. |
and you would need to work with Chinese device manufacturers to determine if there is some FCM replacement that you can use, that will work on the Xiaomi, Huawei, and similar devices
|
Mark M. |
I assume that they have some solution to this problem
|
Mark M. |
personally, I have largely given up on trying to update apps in the background
|
wuqiang |
thanks so much
|
Mark M. |
if you could somehow get away with occasional updates, you can use AlarmManager much as my sample app demonstrates
|
wuqiang |
to check new message ?
|
Mark M. |
where the WakefulIntentService grabs all available messages, but does not attempt to register a listener
|
Mark M. |
this will not run very often once the device reaches Doze mode, though
|
Mark M. |
for most types of apps, that might be acceptable
|
Mark M. |
"chat", however, tends to imply real-time communications
|
wuqiang |
yes
|
Mark M. |
so long as the screen is on and your UI is in the foreground, if you wanted to try your Firebase listener approach, that may be fine
|
Mark M. |
(I do not use Firebase and so I do not know if there are other efficiency issues with your approach)
|
Mark M. |
but the listener approach will not work once the device gets to Doze mode
|
ivano_ndrocchietto |
( Firebase does not give SQL query responses:( GRRR )
|
Apr 24 | 9:40 AM |
wuqiang |
so, let me search a FCM that could use in china
|
Mark M. |
there are plenty of chat-style apps in China, so I assume that there is is some common pattern for how they are implemented
|
Mark M. |
I just do not know the details
|
Mark M. |
let me switch back to ivano...
|
Mark M. |
ivano: your turn! do you have another question?
|
ivano_ndrocchietto |
well yes regarding the submodules in Dagger
|
wuqiang |
thins for you great suggestion
|
Mark M. |
I have never used Dagger
|
ivano_ndrocchietto |
I acnnot understand why I should use them in real life...
|
ivano_ndrocchietto |
OK
|
ivano_ndrocchietto |
did you maybe used so called seams to break up dependencies then?
|
Mark M. |
I am sorry, but I do not understand that question
|
ivano_ndrocchietto |
is a way to test code without using dagger
|
Mark M. |
sure, by writing tests
|
Mark M. |
where DI comes into play is if you have some huge code base, and you need to inject some replacement implementation of something in the middle of it for testing
|
Mark M. |
I try not to have huge code bases
|
Mark M. |
and I try not to need to inject some replacement implementation of something in the middle
|
Mark M. |
my scenarios are different than those of many developers
|
Apr 24 | 9:45 AM |
Mark M. |
I don't have a problem with DI, but I'm not going to use it just for grins and giggles
|
Mark M. |
I have not had a scenario where I needed it, so I have not used it
|
ivano_ndrocchietto |
I see thanks
|
ivano_ndrocchietto |
and sorry for the delay
|
ivano_ndrocchietto |
I am at office:)
|
Mark M. |
no problem
|
Mark M. |
if either of you have any further questions, go ahead
|
wuqiang |
no
|
wuqiang |
thanks
|
Apr 24 | 9:50 AM |
ivano_ndrocchietto |
I have some issue with extensions functions in Kotlin
|
ivano_ndrocchietto |
but I guess for the moment you are not doing any Kotlin being busy with Android SDK right?
|
Mark M. |
correct, I have not played with Kotlin
|
ivano_ndrocchietto |
is quite cool
|
ivano_ndrocchietto |
coll guys say:)
|
ivano_ndrocchietto |
OK no other questions
|
ivano_ndrocchietto |
Ah
|
ivano_ndrocchietto |
I know you do not manage architecture
|
ivano_ndrocchietto |
but would like to know something between the relationship between interactors and presenters
|
ivano_ndrocchietto |
but well is better if I dive personally on that
|
Mark M. |
one problem with architecture discussions is that there is universal definition of terms
|
ivano_ndrocchietto |
so true is so dialectic
|
Mark M. |
for example, I have never heard the term "interactor" used before
|
Apr 24 | 9:55 AM |
Mark M. |
and while I have heard of "presenters", it is clear that their scope varies by who is talking about them :-)
|
Apr 24 | 10:00 AM |
Mark M. |
well, that is a wrap for today's chat
|
Mark M. |
the transcript will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is tomorrow at 7:30pm US Eastern
|
Mark M. |
have a pleasant day!
|
wuqiang | has left the room |
ivano_ndrocchietto | has left the room |
Mark M. | turned off guest access |