Skip to content

Commit afdd3dd

Browse files
Mobile Ads Developer Relationscopybara-github
authored andcommitted
Android Ad Inspector implementation for Unity Bridge.
PiperOrigin-RevId: 764163866
1 parent ff550a4 commit afdd3dd

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2025 Google, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.unity.ads.decagon;
18+
19+
import android.app.Activity;
20+
import com.google.android.libraries.ads.mobile.sdk.MobileAds;
21+
import com.google.android.libraries.ads.mobile.sdk.common.AdInspectorError;
22+
import com.google.android.libraries.ads.mobile.sdk.common.OnAdInspectorClosedListener;
23+
24+
/** Ad inspector implementation for the Google Mobile Ads Unity plugin. */
25+
public final class UnityAdInspector {
26+
27+
private UnityAdInspector() {}
28+
29+
public static void openAdInspector(
30+
final Activity activity, final UnityAdInspectorListener adInspectorListener) {
31+
MobileAds.openAdInspector(
32+
new OnAdInspectorClosedListener() {
33+
@Override
34+
public void onAdInspectorClosed(AdInspectorError adInspectorError) {
35+
if (adInspectorListener != null) {
36+
adInspectorListener.onAdInspectorClosed(adInspectorError);
37+
}
38+
}
39+
});
40+
}
41+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2025 Google, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.unity.ads.decagon;
18+
19+
import com.google.android.libraries.ads.mobile.sdk.common.AdInspectorError;
20+
21+
/**
22+
* Ad inspector interface form of {@link UnityAdInspectorListener} that can be implemented via
23+
* {@code AndroidJavaProxy} in Unity to receive ad inspector events synchronously.
24+
*/
25+
public interface UnityAdInspectorListener {
26+
27+
/**
28+
* Called when the Ad Inspector is closed.
29+
*
30+
* @param error An {@link AdInspectorError} or {@code null} if the inspector closed normally.
31+
*/
32+
void onAdInspectorClosed(AdInspectorError error);
33+
}

0 commit comments

Comments
 (0)