Mar 9 | 7:20 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Mar 9 | 7:25 PM |
Paul R. | has entered the room |
Mark M. |
hello, Paul!
|
Mark M. |
how can I help you today?
|
Paul R. |
Greetings. Ready for another epic?
|
Paul R. |
View paste
(10 more lines)
|
Mark M. |
"Using the app Service lifecycle, will I be able to detect a re-started process versus an in-tact process?" -- um, you can see whether some static field is now null or something
|
Mark M. |
assuming that the detection logic is in the process in question
|
Paul R. |
OK, good enough for the first question.
|
Mark M. |
I'm kinda puzzled by that question, though that may be the lack of sleep talking
|
Ron | has entered the room |
Mark M. |
"Does there need to be any coordination between an alarm (or scheduled job) and the onStartCommand() return value?" -- um, I can't really answer that
|
Mark M. |
(BTW, hello, Ron -- I will be with you in a few minutes!)
|
Paul R. |
Why were you puzzled?
|
Mar 9 | 7:30 PM |
Mark M. |
Paul: unclear what process is what
|
Paul R. |
I see. I am only concerned with the process running the Service.
|
Mark M. |
back to onStartCommand: its return value is fairly orthogonal to your proposed system, in that it feels like you plan on using stopSelf()/stopService() to stop the service
|
Mark M. |
"After the processing timeout occurs (or a "done" state is reached), should the service be stopped?" -- I guess so
|
Mark M. |
"How would I effectively leverage the Android Studio debugger to help develop this code?" -- I don't use multiple processes much, so I cannot really answer that
|
Mark M. |
however, your assumptions are fundamentally flawed
|
Mark M. |
unless by "every few minutes" you really mean "every several hours, when in Doze mode", or you are sure that you will be added to the battery optimization whitelist
|
Paul R. |
I was not sure if I should use the sticky restart from the onStartCommand() or rely on the Alarm. Sounds like relying on the Alarm is good enough.
|
Mark M. |
let me take a question from Ron, and I'll come back to you for more follow-up in a bit
|
Mark M. |
Ron: your turn! do you have a question?
|
Ron |
View paste
|
Mark M. |
the Application singleton and the ContentProviders are created at the same time
|
Mark M. |
in particular, onCreate() of the Application singleton will be called after onCreate() of the ContentProviders
|
Mark M. |
if you have Application initialization that you have to do before the ContentProviders are created...
|
Mar 9 | 7:35 PM |
Mark M. |
...override attachBaseContext() and do it there (plus chain to the superclass)
|
Ron |
That is what we thought but we couldn't find any confirmation. It verifies what we see. Okay we will try that?
|
Mark M. |
you'll see this in the docs for ACRA, for example, as unless you it this way, ACRA won't be able to catch exceptions raised in onCreate() of the providers
|
Mark M. |
this stuff is very undocumented
|
Ron |
Okay, we will look at it. You can go to next question while I look...
|
Mark M. |
OK
|
Mark M. |
Paul: back to you!
|
Mark M. |
(BTW, Ron, see https://github.com/ACRA/acra/wiki/BasicSetup#co... for example)
|
Paul R. |
So you seem to think that I need to ensure that Doze mode is taken into account. Does JobScheduler vs Alarm do this?
|
Paul R. |
is one advantageous over the other?
|
Mark M. |
well, both are affected by Doze mode
|
Mark M. |
in theory, AlarmManager with setAndAllowWhileIdle() lets you kinda get past this
|
Mark M. |
(also setExactAndAllowWhileIdle())
|
Mark M. |
but that's still only every 15 minutes IIRC
|
Mark M. |
and, you won't have Internet access, which presumably is part of what you're doing
|
Paul R. |
Yes, internet is key.
|
Mark M. |
I assume that your option #3 is really "poll the server every so often, looking for messages:
|
Paul R. |
Yes.
|
Mark M. |
Google's trying to get developers away from that, over to FCM
|
Mar 9 | 7:40 PM |
Paul R. |
Right. And they are even providing a new feature Firebase Cloud Functions.
|
Mark M. |
yeah, I haven't heard of that, but I'm assuming its like AWS Lambda
|
Paul R. |
that helps do that withut needing a compute or app engine cpu.
|
Mark M. |
that fits my guess
|
Paul R. |
Could be. I do not know ASW all that well.
|
Mark M. |
though I'm not quite certain how you can use that for your situation
|
Mark M. |
part of what the server needs to do, in a standard FCM setup, is record the FCM IDs of the clients
|
Mark M. |
so that you know how to send messages out
|
Mark M. |
with topic-based messages, I could see how FC Functions could perhaps work
|
Mark M. |
but, I haven't looked at FCM in a couple of years, so I'm probably out of date
|
Paul R. |
I'm worried about scaling. Using FCM with hundres of thousands of Users will not be cheap.
|
Mark M. |
FCM itself is free, or at least it used to be
|
Mark M. |
did they add a pricing model to it now?
|
Paul R. |
The servers are not free.
|
Mark M. |
but the server doesn't have to be on Firebase
|
Mark M. |
your server could be a Raspberry Pi stuffed in an Altoids tin for all FCM cares
|
Paul R. |
No but they need to be in the cloud
|
Mark M. |
they have to be on the Internet
|
Mark M. |
with a static IP address, and probably a domain name
|
Mark M. |
IOW, no different than any other Web service, etc.
|
Paul R. |
Yes, and I do not want to maintain them. Nor do a want a multi-thousand dollar monthly bill.
|
Mar 9 | 7:45 PM |
Mark M. |
um, if you have "hundreds of thousands of users", and you aren't making lots of money, you need to focus on the business model much more than on the tech
|
Mark M. |
and, your option #3 needs a server anyway
|
Paul R. |
It does?
|
Paul R. |
How so?
|
Mark M. |
um, what else were you planning on doing with the Internet, other than talking to a server?
|
Paul R. |
Talking to the Frebase database is already part of the cost of doing business.
|
Mark M. |
in your case, perhaps
|
Paul R. |
The new Functions feature allows it to be a real server.
|
Mark M. |
that statement gives me visions of Pinocchio
|
Paul R. |
How so?
|
Mark M. |
"then I can be a *real* boy!"
|
Mark M. |
sorry, it was just a joke
|
Paul R. |
np
|
Mark M. |
I don't think you'll be able to pull off #3 unless they add you to the battery optimization whitelist
|
Mark M. |
though you are welcome to run experiments and see if you can find some combination of stuff that avoids it
|
Paul R. |
Firebase realizes that just providing a realtime db is not enough. So Functions are a cheap "I'm a server too" fix.
|
Mark M. |
let me take another question from Ron, and I'll return to you shortly
|
Mark M. |
Ron: back to you! do you have another questioon?
|
Mark M. |
er, question?
|
Mar 9 | 7:50 PM |
Ron |
View paste
|
Mar 9 | 7:50 PM |
Paul R. |
What would you do? (I'll take your answer in a minute)
|
Mark M. |
I haven't had any problem setting breakpoints in a library module
|
Mark M. |
I don't know that I have tried actually stepping from an app to a library module
|
Mark M. |
but since I can step into JARs/AARs, I can't imagine that stepping from an app into a library module would somehow be a problem
|
Mark M. |
perhaps your scenario is different than I am picturing, given your question
|
Mark M. |
but most of my open source libraries come with a sample app or two
|
Ron |
We need to debug together, appA is the primary app and we were able to construct appB into a library but we couldn't seem to get it to work. We saw a lot of SO entries saying that only release versions of libraries are compiled.
|
Mark M. |
is this one project or two?
|
Ron |
We are trying them in one project.
|
Mark M. |
I haven't had a problem with that
|
Mark M. |
maybe it's something about how I set up my projects
|
Ron |
Can you point to an example anywhere?
|
Mark M. |
my demo app uses debugCompile project(":name-of-library")
|
Mark M. |
pretty much any of my CWAC projects
|
Ron |
Where is that located?
|
Mark M. | |
Mark M. |
so, for example: https://github.com/commonsguy/cwac-provider
|
Ron |
Okay, we will look at those. You can go to next question.
|
Mar 9 | 7:55 PM |
Mark M. |
in those projects, you'll typically see two modules: a module named after the library (e.g., provider/) and an app module (e.g., demo/)
|
Mark M. |
look at demo/build.gradle to see how I reference the library module
|
Mark M. |
and, I'll come back to you for follow-up in a bit
|
Mark M. |
Paul: over to you!
|
Mark M. |
I can't really answer "what would you do", as I don't really know the overall scenario
|
Mark M. |
I have my own reticence with respect to FCM, though in my case it's avoiding proprietary stuff
|
Mark M. |
in your case, that's not an issue
|
Mark M. |
whether you can get FCM to work in your circumstance, I can't say, as I don't really know what's going on
|
Mark M. |
but FCM is the path of least resistance, in terms of Google providing resistance
|
Paul R. |
I am inclined to try to manage battery drain for my initial release and use Firebase Functions when they are out of Beta.
|
Paul R. |
fwiw.
|
Mark M. |
the problem with "manage battery drain" is that you can't add the app to the battery optimization whitelist yourself -- the user has to do that
|
Mark M. |
IIRC, you can find out whether you are on the whitelist (PowerManager, I think)
|
Paul R. |
? I don't understand. The app is the User, is it not?
|
Mark M. |
usually a human is a user
|
Paul R. |
Or do you mean configure settings?
|
Mark M. |
the human has to configure the Settings app to add your app to the device battery optimization whitelist
|
Paul R. |
Ah, got it.
|
Mark M. |
you cannot programmatically put yourself on that list
|
Mark M. |
and if the human says no, you need to decide what to do
|
Paul R. |
Yuck.
|
Mar 9 | 8:00 PM |
Mark M. |
well, if they didn't do that, the whitelist would be largely pointless
|
Mark M. |
because every developer would just programmatically add their app to it
|
Paul R. |
I have no problem that they chose to do it that way, it is just that it is ugly for my Users.
|
Mark M. |
yup
|
Mark M. |
for certain types of apps, where the target audience is power users, it won't be a big deal
|
Mark M. |
for apps that are aimed at a wider audience, it's not great
|
Mark M. |
there are ways to lead the human to the right spot in Settings... but Google has banned developers from the Play Store if they think that the app should not be doing that
|
Paul R. |
My app is aimed at grandparents and grandchildren. Not exactly power users ... maybe the grandchildren. :-)
|
Mark M. | |
Mark M. |
oy
|
Mark M. |
on the whole, I advise people to try to avoid periodic background work in general now, because the area is such a mess
|
Paul R. |
Good to know.
|
Mark M. |
or, consider periodic background work as an optimization, with manual options (e.g., refresh action bar item) as a visible possibility for users
|
Mark M. |
in your case, it feels like the messaging is fairly central, in which case, you're between a rock and a hard place
|
Mark M. |
FCM is the Google-approved solution, if you can figure out how you can swing it
|
Paul R. |
I'll post a broader description to Stack Overflow. Keep an eye out for it. Might help you get to a million rep points. :-)
|
Mar 9 | 8:05 PM |
Mark M. |
um, OK
|
Mark M. |
let me take another question from Ron, and I'll return to you in a bit
|
Mark M. |
Ron: back to you -- do you have another question?
|
Paul R. |
And my question about DroidCon Boston?
|
Ron | |
Mark M. |
(Paul: nope, they declined my proposal)
|
Ron | has left the room |
Mark M. |
and I may not be available that week anyway
|
Paul R. |
OK. Thanks for your help. Talk to you later.
|
Mark M. |
you're very welcome!
|
Mar 9 | 8:30 PM |
Mark M. |
that's a wrap for today's chat
|
Mark M. |
per usual, the transcript will go up on https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Tuesday, 9am US Eastern
|
Mark M. |
have a pleasant day!
|
Paul R. | has left the room |
Mark M. | turned off guest access |