> For the complete documentation index, see [llms.txt](https://docs.gmetri.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gmetri.com/metaverse/publishing/embed/android-embed.md).

# Android Embed

### Implementing Chrome Custom Tabs for GMetri Experiences[​](https://www.gmetri.com/docs/platform/publish/embed/android-embed#implementing-chrome-custom-tabs-for-gmetri-experiences) <a href="#implementing-chrome-custom-tabs-for-gmetri-experiences" id="implementing-chrome-custom-tabs-for-gmetri-experiences"></a>

To run GMetri experiences inside android apps, we recommend an implementation of Chrome Custom Tabs API. Detailed information on how to setup an android experience with Chrome Custom Tabs can be found in this [experience](https://github.com/gmetrixr/chrome-custom-tabs/).

Also checkout this [link ](/metaverse/publishing/authentication/token.md#creating-jwt-tokens-in-an-android-app)if you need authentication on GMetri experiences within your android app.

In your android experience add the required dependencies for Chrome Custom Tabs. Following is an example of gradle build dependencies:

```groovy
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:customtabs:26.1.0'
}
```

Information on how to install dependencies for other build systems are is in the links below:

<https://developer.chrome.com/multidevice/android/customtabs/>

From this [experience](https://github.com/gmetrixr/chrome-custom-tabs/) , copy 2 files: `ChromeCustomTabs.java` and `ServiceConnectionCallback.java` into your android experience. These files together provide the interface for chrome custom tabs to run GMetri experiences.

The className `ChromeCustomTabs.java` implements 2 public methods:

1. `initialize(String url, Context context)`
2. `launch()`

Arguments:

1. **url** - Url of the experience
2. **context** - Context of your activity (`this`)

An example implementation of the above classes:

```java
  ChromeCustomTabsJwt chromeCustomTabs = new ChromeCustomTabsJwt();
  chromeCustomTabs = new ChromeCustomTabs();
  String url = "https://view.gmetri.com/v4/game/safehands_v2";
  chromeCustomTabs.initialize(url, this);
  chromeCustomTabs.launch();
```

### More About Chrome Custom Tabs

* To enable GMetri XR experiences within an Android app, the app needs to implement the Chrome CustomTabs API as described in this [article](https://developer.chrome.com/multidevice/android/customtabs/).
* Chrome CustomTabs remove the restrictions imposed by WebViews on serving XR content. While WebViews don't share their state with the Chrome browser, ChromeCustomTabs are fully embeddable browser extensions capable of doing anything that a native Chrome browser can do.
* Chrome CustomTabs give apps higher control over web experience and make transitions between native and web content seamless without having to resort to a WebView.

<figure><img src="https://r.vrgmetri.com/raw/gb-web/portal-docs/assets/img/screenshots/performance.gif" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gmetri.com/metaverse/publishing/embed/android-embed.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
