Created
February 10, 2019 12:07
-
-
Save andreban/e0e10588b8cfe7931993822291ef3245 to your computer and use it in GitHub Desktop.
Changing Status Bar colour when launching a TWA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy LauncherActivity from the support library repo | |
// (https://github.com/GoogleChrome/custom-tabs-client/blob/master/customtabs/src/android/support/customtabs/trusted/LauncherActivity.java#L153-L155) | |
// and replace the getCustomTabsIntent method, as below: | |
protected CustomTabsIntent getCustomTabsIntent(CustomTabsSession session) { | |
return new CustomTabsIntent.Builder(session) | |
.setToolbarColor(Color.parseColor("#000000")) | |
.build(); | |
} |
You could override the getLaunchingUrl to return Uri.parse("https://www.example.com/");
Do you mind posting the question on StackOverflow? (https://stackoverflow.com/questions/tagged/trusted-web-activity/). It will make easer for other developers with the same issue to find the answer (and other people can help with the answer too).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this works and sets the status bar color. It does leave the navigation bar white but there doesn't seem to be an API for that so I guess I'll file a bug/feature request.
That said. I ran into an(other) issue.
Not sure if this is the place and I may be hijacking your gist here but for some reason it now launches the splash activity (that's the one I have set as Launcher Activity), then shoves a Custom Tab (with UI) in front of my app with www.example.com. If I close that (press X or Back) I get my TWA.
I had a look at the
android.support.customtabs.trusted.LauncherActivity
class and figured it was returning the fallback value for some reason (SeegetLaunchingUrl()
,return Uri.parse("https://www.example.com/");
). But when I override the method and print super.getLaunchingUrl() it turns out it is returning the correct URL.Any clue what is going on? Thanks!
Manifest:
Splash.java:
WebActivity.java: