Aug 11 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Aug 11 | 4:05 PM |
Randall M. | has entered the room |
Aug 11 | 4:10 PM |
Randall M. |
Hi, Mark.
|
Mark M. |
hello, Randall!
|
Mark M. |
how can I help you today?
|
Randall M. |
I have more of an Android Studio question, than Android specifically...is that OK?
|
Mark M. |
sure
|
Randall M. |
I'm working on a parallel branch of development whilst the client is performing testing and validation. I need to be able to deliver a build of both branches, as needed. And I don't want to blow away data from either installation when the other is installed. I figured out how to change the bundle ID pretty easily based on a "flavor", but there doesn't seem to be a way to change the display app name. Or am I missing how to do this?
|
Mark M. |
I'm not sure what a "bundle ID" is -- do you mean applicationId?
|
Randall M. |
Yes, sorry. (That's my iOS leaking through.)
|
Mark M. |
and by "display app name", you mean like the caption under the icon in the home screen launcher?
|
Randall M. |
In Project Structure > Flavors, it was simple to change the appID,but not the app name. Yes, exactly.
|
Aug 11 | 4:15 PM |
Mark M. |
in your AndroidManifest.xml file, your <activity> that has the MAIN/LAUNCHER <intent-filter> will be getting its label from either an android:label attribute on the <activity> element, or inheriting from the android:label attribute on the <application> element
|
Mark M. |
what value do you have for that android:label attribute? is it a fixed string, or a reference to a string resource (e.g., @string/app_name)?
|
Randall M. |
I have "android:label="@string/app_name"" in both the application and activity.
|
Mark M. |
great!
|
Mark M. |
if you want to change that value in a product flavor, simply redefine that string resource in that flavor
|
Mark M. |
so, in addition to src/main/res/values/strings.xml having an app_name, you would have src/yourflavorname/res/values/strings.xml with its own app_name
|
Mark M. |
(for a flavor cunningly named yourflavorname)
|
Mark M. |
when you build yourflavorname, you'll get that flavor's version of app_name, and that will be what shows up on the home screen launcher icon
|
Randall M. |
That might be part of the problem...I migrated this project from an ant-based IntelliJ project. Do I need to modify the folder structure to support that?
|
Mark M. |
ah
|
Randall M. |
This is the first stuff that's flavor-specific so far.
|
Mark M. |
well, your alternative approach is to try defining it in build.gradle itself
|
Mark M. |
hold on a moment while I quick look up the syntax for that
|
Aug 11 | 4:20 PM |
Mark M. |
OK
|
Mark M. |
right now, in your build.gradle file, you should have a productFlavors {} closure
|
Randall M. |
Check.
|
Mark M. |
in there would be closures for your flavors
|
Mark M. |
in there is where you are overriding the applicationId
|
Randall M. |
Yep.
|
Mark M. | |
Mark M. |
phooey
|
Mark M. |
let me try that again
|
Mark M. | |
Mark M. |
sigh
|
Mark M. |
let me type that into another editor and paste it here -- hold on...
|
Mark M. |
View paste
|
Mark M. |
right?
|
Randall M. |
Yep.
|
Mark M. |
OK
|
Mark M. |
inside that same foo {} closure, you can have a resValue statement
|
Mark M. |
View paste
|
Mark M. |
now, I haven't tried this for having a flavor override a string resource (unless I'm forgetting having tried it -- it's been a long day...)
|
Mark M. |
but it's worth a shot
|
Mark M. |
as it means you won't have to fuss around with your project file structure
|
Randall M. |
Sweet. I will try it.
|
Mark M. |
that being said, eventually shifting over into the standard Android Studio directory structure is probably a good idea
|
Mark M. |
at least for some value of "eventually"
|
Aug 11 | 4:25 PM |
Randall M. |
That's really what I'm trying to avoid...I'm still merging changes between branches, and I think do that will just cause me no end of headaches.
|
Mark M. |
yeah, it's not likely to be a picnic
|
Randall M. |
Yeah, once FDA testing is over and I'm full-time on the new work, I'll try to do that.
|
Randall M. |
Hmmm...looks like I might have to remove that entry from the strings.xml file...
|
Mark M. |
you're getting a complaint about a conflict?
|
Randall M. |
Error:Error: Duplicate resources: ...res/values/strings.xml:string/app_name
|
Mark M. |
yeah, that's what I was afraid of
|
Mark M. |
you should be able to define it purely in build.gradle and remove it from the strings.xml file
|
Randall M. |
There's nothing wrong with removing it from the resource file, eh? Besides being "non-standard"?
|
Mark M. |
not that I'm aware of, though I've never tried it
|
Mark M. |
either have one resValue for every flavor, or put one resValue in defaultConfig and override it in flavors as needed
|
Randall M. |
DING DING DING! We have a winner!
|
Randall M. |
Thanks!
|
Aug 11 | 4:30 PM |
Randall M. |
BTW, I'm the guy that asked you a while back about locking down a "kiosk" mode, pre-Lollipop. I got everything working as desired, nearly 100%. The only crack is the Recent Apps list; despite flagging it to not appear there, it does, ever so briefly, allowing the user a small windows to swipe to quit. But other than that...Back button, Home button, power key, status bar...locked down tight.
|
Mark M. |
to a large extent, I'm actually sorry to hear that
|
Randall M. |
heh
|
Mark M. |
while your use case is fine, there are lots of other less-fine use cases for that sort of stuff
|
Randall M. |
I agree that for a "normal" app, yeah, that would be annoying/irritating as an end user.
|
Mark M. |
as I told somebody on Stack Overflow recently, just because you are a saint does not mean that all malware developers are magically becoming saints
|
Randall M. |
Yeah.
|
Randall M. |
Are you very familiar with making custom Android distros? That's probably the root my client *should* take, but I have no idea the scope of that.
|
Mark M. |
I have never created one
|
Randall M. |
They're actually talking about making the app available via the Play store, which I think would be bad.
|
Mark M. |
whoever is advising your firm on FDA approval probably ought to weigh in on public distribution like that
|
Mark M. |
IOW, is it FDA-approved if users install it, vs. getting the app pre-installed on hardware?
|
Randall M. |
BTW, are you going to be happen to be a the BABBQ conference in TX in Oct?
|
Mark M. |
no, sorry, I'm not attending the BBQ
|
Mark M. |
back to distros
|
Aug 11 | 4:35 PM |
Randall M. |
Yeah, I don't know how the FDA requirements fit into an end-user installation.
|
Mark M. |
for low-level, how to bring up a custom Android build on hardware, try Karim Yaghmour's _Embedded Android_
|
Mark M. |
I was hoping that by now, we'd have more turnkey services for custom ROMs, but that hasn't come to pass
|
Mark M. |
drivers tend to be the big sticking point
|
Randall M. |
I imagine.
|
Randall M. |
Thanks for the tip.
|
Randall M. |
Thanks again for your help. Have a great day!
|
Mark M. |
you are very welcome
|
Aug 11 | 4:40 PM |
Randall M. | has left the room |
Aug 11 | 5:00 PM |
Mark M. | turned off guest access |