質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Facebook

Facebookは、実名登録制のSNS(ソーシャル・ネットワーキング・サービス)です。開発者用のデベロッパーサイトが存在し、一般ユーザーによるFacebook向けアプリケーション開発が可能です。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

0回答

787閲覧

androidアプリで、Audience NetworkのNative Banner Adsを導入したいがタップできない

tamago83

総合スコア60

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Facebook

Facebookは、実名登録制のSNS(ソーシャル・ネットワーキング・サービス)です。開発者用のデベロッパーサイトが存在し、一般ユーザーによるFacebook向けアプリケーション開発が可能です。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

0クリップ

投稿2021/07/15 01:45

前提・実現したいこと

androidアプリで、recycler viewの中にAudience NetworkのNative Banner Adsを導入したい。

発生している問題・エラーメッセージ

広告は出るのですが、タップすることはできません。
インターステーショナル、バナーは問題なくできております。

該当のソースコード

kotlin

1class RssListAdapter(private val activity: AppCompatActivity) 2 : RecyclerView.Adapter<RecyclerView.ViewHolder>() { 3 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { 4 return FaceBookViewHolder(activity, itemView) 5 } 6 override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) { 7 (viewHolder as ViewHolderInterface).onBindViewHolder() 8 } 9}

kotlin

1interface ViewHolderInterface { 2 fun onBindViewHolder() 3}

xml

1<?xml version="1.0" encoding="utf-8"?> 2<com.facebook.ads.NativeAdLayout 3 android:id="@+id/native_banner_ad_container" 4 android:layout_width="match_parent" 5 android:layout_height="wrap_content" 6 android:layout_alignParentBottom="true" 7 xmlns:android="http://schemas.android.com/apk/res/android"> 8 <LinearLayout 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 android:orientation="vertical"> 12 <LinearLayout 13 android:layout_width="match_parent" 14 android:layout_height="wrap_content" 15 android:orientation="horizontal"> 16 17 <RelativeLayout 18 android:id="@+id/ad_choices_container" 19 android:layout_width="wrap_content" 20 android:layout_height="wrap_content" 21 android:padding="2dp" /> 22 23 <TextView 24 android:id="@+id/native_ad_sponsored_label" 25 android:layout_width="wrap_content" 26 android:layout_height="wrap_content" 27 android:layout_gravity="center_vertical" 28 android:ellipsize="end" 29 android:lines="1" 30 android:padding="2dp" 31 android:textColor="@android:color/darker_gray" 32 android:textSize="12sp" /> 33 </LinearLayout> 34 35 <RelativeLayout 36 android:layout_width="match_parent" 37 android:layout_height="wrap_content" 38 android:background="@android:color/white"> 39 40 <com.facebook.ads.MediaView 41 android:id="@+id/native_icon_view" 42 android:layout_width="50dp" 43 android:layout_height="50dp" 44 android:layout_alignParentLeft="true" 45 android:layout_alignParentStart="true" 46 android:gravity="center" /> 47 48 <LinearLayout 49 android:layout_width="match_parent" 50 android:layout_height="wrap_content" 51 android:layout_centerVertical="true" 52 android:orientation="vertical" 53 android:paddingLeft="53dp" 54 android:paddingRight="83dp"> 55 56 <TextView 57 android:id="@+id/native_ad_title" 58 android:layout_width="match_parent" 59 android:layout_height="wrap_content" 60 android:ellipsize="end" 61 android:lines="1" 62 android:textColor="@android:color/black" 63 android:textSize="15sp" 64 android:textStyle="bold" /> 65 66 <TextView 67 android:id="@+id/native_ad_social_context" 68 android:layout_width="match_parent" 69 android:layout_height="wrap_content" 70 android:ellipsize="end" 71 android:lines="1" 72 android:textSize="12sp" /> 73 </LinearLayout> 74 75 <Button 76 android:id="@+id/native_ad_call_to_action" 77 android:layout_width="80dp" 78 android:layout_height="50dp" 79 android:layout_alignParentEnd="true" 80 android:layout_alignParentRight="true" 81 android:background="#4286F4" 82 android:gravity="center" 83 android:paddingLeft="3dp" 84 android:paddingRight="3dp" 85 android:textColor="@android:color/white" 86 android:textSize="12sp" 87 android:visibility="gone" /> 88 89 </RelativeLayout> 90 </LinearLayout> 91</com.facebook.ads.NativeAdLayout>

kotlin

1class FaceBookViewHolder(private val activity: AppCompatActivity, private val itemView: View) : RecyclerView.ViewHolder(itemView), ViewHolderInterface { 2 override suspend fun onBindViewHolder(infoModel: RssInfoItemModel, position: Int): Unit = withContext(Dispatchers.Main){ 3 val nativeBannerAd = NativeBannerAd(activity, "CAROUSEL_IMG_SQUARE_LINK#xxxx_xxxx") 4 val nativeAdLayout: NativeAdLayout = itemView.findViewById(R.id.native_banner_ad_container) 5 nativeBannerAd.loadAd( 6 nativeBannerAd.buildLoadAdConfig() 7 .withAdListener(object: NativeAdListener{ 8 override fun onError(p0: Ad?, p1: AdError?) { 9 Qlog.d("facebook onError: ${p1!!.errorCode}, ${p1!!.errorMessage}") 10 } 11 12 override fun onAdLoaded(p0: Ad?) { 13 Qlog.d("facebook onAdLoaded") 14 15 if(nativeBannerAd == p0){ 16 Qlog.d("facebook nativeBannerAd == p0") 17 nativeBannerAd.unregisterView() 18 19 // Add the AdChoices icon 20 val adChoicesContainer = itemView.findViewById<RelativeLayout>(R.id.ad_choices_container) 21 val adOptionsView = AdOptionsView(activity, nativeBannerAd, nativeAdLayout) 22 adChoicesContainer.removeAllViews() 23 adChoicesContainer.addView(adOptionsView, 0) 24 25 // Create native UI using the ad metadata. 26 val nativeAdTitle: TextView = itemView.findViewById(R.id.native_ad_title); 27 val nativeAdSocialContext: TextView = itemView.findViewById(R.id.native_ad_social_context); 28 val sponsoredLabel: TextView = itemView.findViewById(R.id.native_ad_sponsored_label); 29 val nativeAdIconView: MediaView = itemView.findViewById(R.id.native_icon_view); 30 val nativeAdCallToAction: Button = itemView.findViewById(R.id.native_ad_call_to_action); 31 32 // Set the Text. 33 nativeAdCallToAction.text = nativeBannerAd.adCallToAction; 34 nativeAdCallToAction.visibility = if(nativeBannerAd.hasCallToAction()) { 35 View.VISIBLE 36 }else{ 37 View.INVISIBLE 38 } 39 nativeAdTitle.text = nativeBannerAd.advertiserName; 40 nativeAdSocialContext.text = nativeBannerAd.adSocialContext; 41 sponsoredLabel.text = nativeBannerAd.sponsoredTranslation; 42 43 nativeBannerAd.registerViewForInteraction( 44 nativeAdLayout 45 , nativeAdIconView 46 , arrayListOf<View>(nativeAdTitle, nativeAdCallToAction) 47 ); 48 } 49 50 } 51 52 override fun onAdClicked(p0: Ad?) { 53 Qlog.d("facebook onAdClicked") 54 } 55 56 override fun onLoggingImpression(p0: Ad?) { 57 Qlog.d("facebook onLoggingImpression") 58 } 59 60 override fun onMediaDownloaded(p0: Ad?) { 61 Qlog.d("facebook onMediaDownloaded") 62 } 63 64 }) 65 .withMediaCacheFlag(NativeAdBase.MediaCacheFlag.ALL) 66 .build()) 67 } 68} 69

試したこと

native ads、native templateも試しましたが、同様にタップ、画面遷移ができませんでした。

補足情報(FW/ツールのバージョンなど)

端末
android 11
ライブラリ
audience-network-sdk:6.5.1
androidx.recyclerview:recyclerview:1.2.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問