The YouTube Mobile Live deep link enables Android applications to initiate a
YouTube livestream directly from a mobile device. An app only needs to provide
an entry point, such as a button that the user can click, that starts the Mobile
Live flow using the Android Intent mechanism.

## Example

This flow shows the user experience for an app that deep links into the YouTube
application, where the user lands on the Mobile Livestream Setup screen.

1. First, the user configures the stream, setting the title, privacy mode, and other stream options.
2. Then, the user navigates to the Thumbnail Photo screen to set a thumbnail image for the stream.
3. Finally, the user starts the livestream and broadcasts the view from the front or rear camera.

![Mobile livestream setup screen](https://developers.google.com/static/youtube/android/live/images/mobile-live-intent1.png)
![Thumbnail photo screen](https://developers.google.com/static/youtube/android/live/images/mobile-live-intent2.png)
![Mobile livestream broadcast screen](https://developers.google.com/static/youtube/android/live/images/mobile-live-intent3.png)

## Device Requirements

Android devices must meet the following requirements to properly support YouTube
live streaming and the Mobile Live deep link:

- **Android release:** Marshmallow (API 23) or higher
- **Camera:** At least one camera capable of recording 720p at at least 30Hz
- **Microphone:** Onboard microphone
- **Audio encoder:** Hardware accelerated audio encoder capable of encoding 8-bit PCM mono audio to AAC at 44.1KHz or better
- **Video encoder:** Hardware accelerated video encoder capable of encoding 720P raw video to H.264/AVC at 30Hz or better
- **YouTube app installed:** Version 13.02 or higher

## Mobile Live Intent specification

To link into the YouTube Mobile live streaming flow, your Android app launches
an
[Intent](https://developer.android.com/reference/android/content/Intent.html).
The Intent initiates the live streaming process by starting an
[Activity](https://developer.android.com/guide/components/activities.html) in
the YouTube application.

### Intent format

The Mobile Live Intent uses a custom `Action` string to navigate to the live
creation Activity within the YouTube app. It also specifies the package name for
the YouTube mobile app.

- [Action](https://developer.android.com/reference/android/content/Intent.html#setAction(java.lang.String)): "`com.google.android.youtube.intent.action.CREATE_LIVE_STREAM`"
- [Package](https://developer.android.com/reference/android/content/Intent.html#setPackage(java.lang.String)): "`com.google.android.youtube`"

### Intent extras

The YouTube application setup flow handles the stream configuration. The
following Intent extras set parameters associated with the livestream:

| Params ||
|---|---|
| **Intent.[EXTRA_REFERRER](https://developer.android.com/reference/android/content/Intent.html#EXTRA_REFERRER)** | **Required** . This parameter specifies a URI that represents the application launching the live streaming Activity. This value must follow the `android-app: scheme` format with a package name. The value enables accurate attribution and accounting. |
| **Intent.[EXTRA_SUBJECT](https://developer.android.com/reference/android/content/Intent.html#EXTRA_SUBJECT)** | **Optional** . This parameter provides a text description of the livestream. It is placed in the Intent extras bundle as a [String](https://developer.android.com/reference/java/lang/String.html). The value can be used to annotate the stream with a branded message, such as "Streamed live from DEVICE". |

## Launching the live streaming flow

Complete the following two steps to verify device compatibility and start the
Mobile Live Activity from your Android app.

### Step 1: Check for support

Your client should first confirm that the Mobile Live Intent can be launched by
verifying that the YouTube app is installed on the device and that the YouTube
app version supports live streaming. The following code sample defines two
methods to do that:

- The `canResolveMobileLiveIntent` method verifies that the device supports the
  Mobile Live Intent.

- The `validateMobileLiveIntent` calls the `canResolveMobileLiveIntent` method
  in the context of an `if-else` statement.

  - If the device supports the Intent, then the device could launch the livestream flow.
  - If the device does not support the Intent, then the device could prompt the user to install or upgrade the YouTube app.

```java
private boolean canResolveMobileLiveIntent(Context context) {
  Intent intent = new Intent("com.google.android.youtube.intent.action.CREATE_LIVE_STREAM")
    .setPackage("com.google.android.youtube");
  PackageManager pm = context.getPackageManager();
  List<ResolveInfo> resolveInfo =
    pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
  return resolveInfo != null && !resolveInfo.isEmpty();
}


private void validateMobileLiveIntent(Context context) {
  if (canResolveMobileLiveIntent(context)) {
    // Launch the livestream Activity
  } else {
    // Prompt user to install or upgrade the YouTube app
  }
}
```

Apps targeting Android 11 (API level 30) or higher must declare the
[package visibility](https://developer.android.com/training/package-visibility)
requirements in the `AndroidManifest.xml` file so that `PackageManager` can
query the YouTube application:

```xml
<queries>
  <package android:name="com.google.android.youtube" />
  <intent>
    <action android:name="com.google.android.youtube.intent.action.CREATE_LIVE_STREAM" />
  </intent>
</queries>
```

### Step 2: Launch the livestream activity

To start the live streaming flow, your client app creates and launches an Intent
as shown in the following code sample:

```java
private Intent createMobileLiveIntent(Context context, String description) {
  Intent intent = new Intent("com.google.android.youtube.intent.action.CREATE_LIVE_STREAM")
      .setPackage("com.google.android.youtube");
  Uri referrer = new Uri.Builder()
      .scheme("android-app")
      .appendPath(context.getPackageName())
      .build();

  intent.putExtra(Intent.EXTRA_REFERRER, referrer);
  if (!TextUtils.isEmpty(description)) {
    intent.putExtra(Intent.EXTRA_SUBJECT, description);
  }
  return intent;
}


private void startMobileLive(Context context) {
  Intent mobileLiveIntent = createMobileLiveIntent(context, "Streaming via ...");
  startActivity(mobileLiveIntent);
}
```