GoogleChrome / GoogleChrome/android-browser-helper
[BUG] Custom Tab height doesn't change
- Dominant language
- Java
- Stars
- 832
- Forks
- 370
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
**Describe the bug**
Related with this issue: https://github.com/GoogleChrome/android-browser-helper/issues/441.
After realising that I need to send as parameter a session or open the Custom tab via `startActivityForResult` to be able to have it in a bottom sheet (as it says in the [docs](https://developer.chrome.com/docs/android/custom-tabs/guide-partial-custom-tabs/?cmdf=custom+tabs+partial+custom+tab), thanks @sebastianbenz), I could make it by using `registerForActivityResult` (which substitutes `startActivityForResult`, it's deprecated). Now that I have my Custom tab in a bottom sheet, I would like to customize its height, but I'm not able to, it always stays at the 50% of the screen height whatever number I pass as parameter to the `setInitialActivityHeight` method.
I tried modifying the number in `PartialCustomTabActivity.java` in the `custom-tabs-example-app` in this same repo, and the bug seems to be there too, the bottom sheet is always 50% of the screen. I also tried in several different devices.
**To Reproduce**
Steps to reproduce the behavior:
1. Construct a new `CustomTabsIntent.Builder` indicating the desired height with `setInitialActivityHeightPx()`.
2. Get the `CustomTabsIntent` from the builder and set the desired Uri as `intent.data`.
3. Launch the intent via a launcher created via `registerForActivityResult`.
4. Custom tab is launched in a resizable bottom sheet but always with the same height (50% of the screen), no matter which valid number I pass in step 1.
**Expected behavior**
The Custom tab appears in a bottom sheet with the specified height.
**Did this ever used to work**
I couldn't make it work, neither in my project nor in the `custom-tabs-example-app` project of this repo.
**Screenshots**
No need screenshots here.
**Code Snippets**
```
private val customTabsLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
// ...
}
val customTabsBuilder = CustomTabsIntent.Builder().setInitialActivityHeightPx(500)
val customTabsIntent = customTabsBuilder.build()
customTabsIntent.intent.data = Uri.parse("www.example.com")
customTabsLauncher.launch(customTabsIntent.intent)
```
**Smartphone (please complete the following information):**
- Device: Samsung Galaxy S9
- OS: Android 9
- Browsers Installed: Google Chrome
- Browser Versions: 117.0.5938.60
- android-browser-helper library version: 1.5.0
and
- Device: Google Pixel 7
- OS: Android 13
- Browsers Installed: Google Chrome
- Browser Versions: 117.0.5938.60
- android-browser-helper library version: 1.5.0
Contributor guide
Assessment
This issue has not been assessed yet.