If you have a signal provider SDK that generates real-time bidding (RTB)
signals, you can develop a secure signal adapter to let Google Mobile Ads SDK (Legacy) collect
signals from your SDK.

Google Mobile Ads SDK (Legacy) forwards your signals to selected participating [Authorized
Buyers](https://support.google.com/authorizedbuyers/answer/6138000) and [Open
Bidding](https://support.google.com/admanager/answer/7128453) buyers.

The following diagram illustrates the request-response lifecycle for secure
signal collection:
![](https://developers.google.com/static/admob/images/secure_signal_diagram_android.png)

A secure signal adapter is responsible for adapter initialization and signal
collection.

## Implement a secure signal adapter

Implement a secure signal adapter for Google Mobile Ads SDK (Legacy) to collect signals from
your SDK.

This guide covers how to implement a secure signal adapter by

extending the `RtbAdapter` abstract class.


The following example

extends the `RtbAdapter` abstract class:

### Java

```java
public class SampleAdapterSnippets extends RtbAdapter {
```

### Initialize the adapter

Google Mobile Ads SDK (Legacy) calls the

`initialize()` method

when Google Mobile Ads SDK (Legacy) instantiates your secure signal adapter. Use this method to
initialize your SDK.

When your SDK initializes fully and is ready for Google Mobile Ads SDK (Legacy) to collect
signals, call the

`InitializationCompleteCallback` callback.


If your secure signals adapter doesn't call back, Google Mobile Ads SDK (Legacy) doesn't collect
signals from your secure signal adapter.

The following example calls the completion

callback

to inform Google Mobile Ads SDK (Legacy) that your SDK has initialized successfully:

### Java

```java
@Override
public void initialize(
    Context context,
    InitializationCompleteCallback initializationCompleteCallback,
    List<MediationConfiguration> configurations) {

  // Add your SDK initialization logic here.

  // Invoke the InitializationCompleteCallback once initialization completes.
  initializationCompleteCallback.onInitializationSucceeded();
}

```

> [!NOTE]
> **Note:** Initialization must complete within 30 seconds. Google Mobile Ads SDK (Legacy) calls this method only once per session.

### Report adapter and SDK version

Your secure signal adapter must report both your adapter version and your SDK
version. Google Mobile Ads SDK (Legacy) uses these versions for reporting and troubleshooting.

If your SDK implements this adapter in the same binary, you can return the same
version for both the adapter and SDK versions.

The following example returns the version of your secure signal adapter:

### Java

```java
@Override
public VersionInfo getVersionInfo() {
  // If your SDK implements this adapter in the same binary, return
  // the same version as your SDK.
  // return getSDKVersionInfo();

  // If you built a separate binary for this adapter, return
  // the adapter's version here.
  int major = 4;
  int minor = 5;
  int micro = 6;
  return new VersionInfo(major, minor, micro);
}

```

The following example returns the version of your SDK that your secure signal
adapter interacts with:

### Java

```java
@Override
public VersionInfo getSDKVersionInfo() {

  // Return your SDK's version string here.
  String versionString = SDK_VERSION_STRING;
  String[] splits = versionString.split("\\.");
  if (splits.length >= 3) {
    try {
      int major = Integer.parseInt(splits[0]);
      int minor = Integer.parseInt(splits[1]);
      int micro = Integer.parseInt(splits[2]);
      return new VersionInfo(major, minor, micro);
    } catch (NumberFormatException e) {
      // Fall through to log warning and return 0.0.0.
    }
  }

  Log.w(
      TAG,
      String.format(
          "Unexpected SDK version format: %s. Returning 0.0.0 for SDK version.", versionString));
  return new VersionInfo(0, 0, 0);
}
```

Replace <var class="readonly" translate="no">SDK_VERSION_STRING</var> with your SDK version
string.

### Collect signals

On every ad request, Google Mobile Ads SDK (Legacy) collects signals simultaneously from all
adapters on a background thread.

The following example collects and returns signals to Google Mobile Ads SDK (Legacy)

by calling the `SignalCallbacks.onSuccess()` method:


### Java

```java
@Override
public void collectSignals(RtbSignalData rtbSignalData, SignalCallbacks signalCallbacks) {

  // Add your signal collection logic here.
  String signals = SAMPLE_SIGNAL_PLACEHOLDER;

  // Return the signals as a string to the Google Mobile Ads SDK.
  signalCallbacks.onSuccess(signals);
}
```

Replace <var class="readonly" translate="no">SAMPLE_SIGNAL_PLACEHOLDER</var> with your secure
signal string.

Signal collection must complete within one second. If signal collection takes
longer than one second, consider caching signals in your secure signal adapter
or your SDK when you [initialize the adapter](https://developers.google.com/ad-manager/mobile-ads-sdk/android/secure-signal-adapter.md.txt#initialize_the_adapter).

If your secure signal adapter fails to collect signals,

pass an error to the `signalCallbacks.onFailure()` method.


#### Obfuscate signals

When you [share secure signals with bidders and curation
partners](https://support.google.com/admanager/answer/10488752), you must obfuscate
the signals.