原生广告:如何使用CustomTemplateAd访问打开浏览器的URL

时间:2017-12-19 13:42:33

标签: android admob google-dfp

我正在我的Android应用中实现原生自定义模板广告,在我的代码中,我在我的视图中提取并呈现自定义模板广告。我想在用户使用我在dfp门户网站中设置的点击Webview点击广告时打开URL,但我没有看到任何方法或文档如何获取URL

来自nativeCustomTemplateAd.getAvailableAssetNames();我只得到三个密钥,其中没有一个是URL密钥。如何获取“f”中的网址,如屏幕截图所示。


enter image description here

如何获取广告网址?

5 个答案:

答案 0 :(得分:0)

old_dictionary = {
1241:{
'name': 'Anakin',
'last_name': 'Skywalker',},

1215:{
'name':'someotherguy',
}
}
new_dictionary = {
1241:{
'name':'Darth',
'last_name':'Vader'
}
}

def compare(old_dictionary, new_dictionary):
    result = {}
    for key in old_dictionary:
        if key in new_dictionary:
            if old_dictionary[key] == new_dictionary[key]:
                result[key] = 'NO CHANGE'
            else :
                result[key] = 'UPDATE'
        else :
            result[key] = 'DELETE'
    return result

In [1] : print(compare(old_dictionary, new_dictionary))
Out[1] : {1241: 'UPDATE', 1215: 'DELETE'}

答案 1 :(得分:0)

 recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (!recyclerView.canScrollVertically(1))
                onScrolledToBottom();
        }
    });

private void onScrolledToBottom() {
    if (songMainList.size() < songAllList.size()) {
        int x, y;
        if ((songAllList.size() - songMainList.size()) >= 50) {
            x = songMainList.size();
            y = x + 50;
        } else {
            x = songMainList.size();
            y = x + songAllList.size() - songMainList.size();
        }
        for (int i = x; i < y; i++) {
            songMainList.add(songAllList.get(i));
        }
        songsAdapter.notifyDataSetChanged();
    }

}

答案 2 :(得分:0)

                <?xml version="1.0" encoding="utf-8"?>
                <layout
                        xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
                        xmlns:android="http://schemas.android.com/apk/res/android">
                    <androidx.core.widget.NestedScrollView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:fillViewport="true">
                        <androidx.constraintlayout.widget.ConstraintLayout
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                        >
                            <TextView
                                    android:text="TextView dsaf   fdkfd fdfdf  dkljdnfd dkfndf dfdkjn fdfdkjnf  dfkdn dfdkjnd dfdjfdfn df"
                                    android:layout_width="0dp"
                                    android:maxLines="2"
                                    android:textSize="14sp"
                                    android:textColor="#01050A"
                                    android:ellipsize="end"
                                    android:textStyle="bold|italic"

                                    app:layout_constraintLeft_toRightOf="parent"
                                    android:layout_height="wrap_content"
                                    android:id="@+id/textView3" android:layout_marginTop="8dp"
                                    app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
                                    android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                                    android:layout_marginEnd="8dp"
                                    app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
                            />
                            <TextView
                                    android:text="TextView"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:id="@+id/textView4" app:layout_constraintStart_toStartOf="parent"
                                    app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                                    android:layout_marginRight="8dp"
                                    app:layout_constraintTop_toBottomOf="@+id/textView3" app:layout_constraintHorizontal_bias="0.0"
                                    android:layout_marginLeft="8dp" android:layout_marginStart="8dp"/>

                            <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"
                                          android:weightSum="4"
                                          android:orientation="horizontal"
                                          android:padding="5dp"
                                          tools:layout_editor_absoluteX="0dp" android:layout_marginTop="8dp"
                                          app:layout_constraintTop_toBottomOf="@+id/textView4" android:id="@+id/linearLayout">
                                <LinearLayout android:layout_width="0dp"
                                              android:layout_height="wrap_content"
                                              android:layout_weight="1"
                                              android:gravity="center"
                                              android:layout_gravity="center"
                                              android:orientation="vertical">
                                    <ImageView
                                            android:layout_width="wrap_content"
                                            android:layout_height="40dp" app:srcCompat="@mipmap/ic_launcher_round"
                                            android:id="@+id/imageView3"


                                    />
                                    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                              android:text="Test122"/>
                                </LinearLayout>
                                <LinearLayout android:layout_width="0dp"
                                              android:layout_height="wrap_content"
                                              android:layout_weight="1"
                                              android:gravity="center"
                                              android:layout_gravity="center"
                                              android:orientation="vertical">
                                    <ImageView
                                            android:layout_width="wrap_content"
                                            android:layout_height="40dp" app:srcCompat="@mipmap/ic_launcher_round"
                                            android:id="@+id/imageView7"></ImageView>
                                    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                              android:text="Test122"/>
                                </LinearLayout>
                                <LinearLayout android:layout_width="0dp"
                                              android:layout_height="wrap_content"
                                              android:layout_weight="1"
                                              android:gravity="center"
                                              android:layout_gravity="center"
                                              android:orientation="vertical">
                                    <ImageView
                                            android:layout_width="wrap_content"
                                            android:layout_height="40dp" app:srcCompat="@mipmap/ic_launcher_round"
                                            android:id="@+id/imageView8"
                                            android:layout_weight="1"
                                    />
                                    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                              android:text="Test122"/>
                                </LinearLayout>
                                <LinearLayout android:layout_width="0dp"
                                              android:layout_height="wrap_content"
                                              android:layout_weight="1"
                                              android:gravity="center"
                                              android:layout_gravity="center"
                                              android:orientation="vertical">
                                    <ImageView
                                            android:layout_width="wrap_content"
                                            android:layout_height="40dp" app:srcCompat="@mipmap/ic_launcher_round"
                                            android:id="@+id/imageView82"
                                            android:layout_weight="1"
                                    />
                                    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                                              android:text="Test122"/>
                                </LinearLayout>
                            </LinearLayout>
                            <TextView
                                    android:text="TextView"
                                    android:background="#9B9A9A"
                                    android:layout_width="match_parent"
                                    android:layout_height="0.5dp"
                                    android:id="@+id/textView5" app:layout_constraintStart_toStartOf="parent"
                                    android:layout_marginLeft="0dp" android:layout_marginStart="0dp"
                                    app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="0dp"
                                    android:layout_marginRight="0dp" app:layout_constraintTop_toBottomOf="@+id/linearLayout"
                                    android:layout_marginTop="8dp"/>
                            <androidx.recyclerview.widget.RecyclerView
                                    android:layout_width="match_parent"
                                    android:layout_height="0dp"
                                    android:visibility="visible"
                                    tools:layout_editor_absoluteX="0dp" app:layout_constraintTop_toBottomOf="@+id/textView5"
                                    app:layout_constraintBottom_toBottomOf="parent" android:id="@+id/recyclerView"/>

                            <ProgressBar
                                    android:id="@+id/progressBar"
                                    android:layout_width="100dp"
                                    android:layout_height="100dp"
                                    android:indeterminateDrawable="@drawable/circular_progress_bar"
                                    android:layout_marginBottom="8dp"
                                    app:layout_constraintBottom_toBottomOf="parent"
                                    android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
                                    android:layout_marginLeft="8dp" android:layout_marginEnd="8dp"
                                    app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
                                    android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/textView5"
                                    app:layout_constraintVertical_bias="0.050000012"/>
                        </androidx.constraintlayout.widget.ConstraintLayout>
                    </androidx.core.widget.NestedScrollView>
                </layout>

            https://github.com/SalmanZach/Springy_Facebook_Rebound
            https://github.com/alitamoor65/BannerAdsInRecyclerView
        https://github.com/xzwszl/Marquee
    https://github.com/TonnyL/Spark
    https://github.com/skydoves/AndroidRibbon
    https://github.com/NoNews/NoPaginate
stackoverflow.com/questions/tagged/android

答案 3 :(得分:0)

What is use of data binding in Android?
What is data binding with example?
Is Android data binding useful?
What is 2way binding?
What is the difference between one way binding and two way binding?
How do I enable DataBinding?
What is bind view in Android?
What is LiveData Android?
What is a ViewModel Android?
What does a ViewModel do?
What is RxJava?
Why RxJava is used in Android?
What is difference between RxJava and RxAndroid?
What is the difference between View and ViewModel?
What is MVP Android?
What is Mvvm Android?
What is the difference between LiveData and MutableLiveData?
How does LiveData work?
What is MediatorLiveData?
What are observables in Android?
Which is better MVP or MVVM Android?
Which is faster: SQLite or MySQL?

答案 4 :(得分:0)

我也遇到了这种情况。无法通过NativeCustomTemplateAd对象访问点击URL。要在用户点击广告时在网络视图中打开广告,请将点击后到达网址添加到可选字段(例如 StandardURL )中,当用户点击广告时,请致电nativeCustomTemplateAd.getText("StandardURL").toString()将该网址加载到Web视图中。