【问题标题】:AdMob banner ads in assets folder HTML files资产文件夹 HTML 文件中的 AdMob 横幅广告
【发布时间】:2020-05-29 17:02:51
【问题描述】:

是否可以将 AdMob 横幅广告添加到资产文件夹 HTML 文件中? 我使用 recyclerview 为列表和资产文件夹制作了一本电子书,其中包含包含相关标题内容的 HTML 文件。我在 Activity_Main 中添加了一个 AdMob 横幅,其中显示了标题列表。而现在想在 assets 文件夹中的内容中添加一个类似的横幅广告。

PS 这是我构建的第一个应用程序,通过 Youtube 和 Stackoverflow 等其他网站学习

公共类 MainActivity 扩展 AppCompatActivity {

private static final String TAG = "MainActivity";
private Context mContext;

ArrayList<String> titleArrayList;
private RecyclerView mRecyclerView;
    AdView mAdView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });
        mAdView = findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            // Code to be executed when an ad finishes loading.
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            // Code to be executed when an ad request fails.
        }

        @Override
        public void onAdOpened() {
            // Code to be executed when an ad opens an overlay that
            // covers the screen.
        }

        @Override
        public void onAdClicked() {
            // Code to be executed when the user clicks on an ad.
        }

        @Override
        public void onAdLeftApplication() {
            // Code to be executed when the user has left the app.
        }

        @Override
        public void onAdClosed() {
            // Code to be executed when the user is about to return
            // to the app after tapping on an ad.
        }
    });

    mContext = MainActivity.this;

    titleArrayList = new ArrayList<String>();
    titleArrayList.add(Constants.Title_1);
    titleArrayList.add(Constants.Title_2);
    titleArrayList.add(Constants.Title_3);
    titleArrayList.add(Constants.Title_4);
    titleArrayList.add(Constants.Title_5);



    mRecyclerView = (RecyclerView) findViewById(R.id.title_layout_RecyclerView);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));

    TitleAdapter adapter = new TitleAdapter(mContext, titleArrayList, new CustomItemClickListener() {
        @Override
        public void onItemClick(View v, int position) {

            Intent desIntent = new Intent(mContext,DescriptionActivity.class);

            desIntent.putExtra("titles",titleArrayList.get(position));

            startActivity(desIntent);
            Toast.makeText(mContext, "clicked"+titleArrayList.get(position), Toast.LENGTH_SHORT).show();


        }
    });

    mRecyclerView.setAdapter(adapter);
}

}

【问题讨论】:

    标签: java android android-studio admob assets


    【解决方案1】:

    AdMob SDK 严格来说只是原生的。对于“html”或网站上的广告,您必须通过 AdSense 进行。

    为此,您必须通过提交您的网站网址在 ​​AdSense 中提出请求。

    最重要的是,您无法使用 AdMob SDK 做到这一点,最好在底部放置横幅广告。或者,您可以在用户在不同的 html 页面之间切换或经过一定时间后放置插页式广告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多