AdMob banner ads in assets folder HTML files

Viewed 193

Is it possible to add AdMob banner ads to the assets folder HTML files? I have made a Ebook using a recyclerview for the list and assets folder containing HTML files containing the content of the relevant title. I have added a AdMob banner to Activity_Main where the list of titles are present. And now want to add a similar banner ads to the content in the assets folder.

PS This is the first app I build, learning through Youtube and other sites like Stackoverflow

public class MainActivity extends 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);
}

}

1 Answers

AdMob SDK is strictly native only. For ads on 'html' or websites, you'd have to do it via AdSense.

For this you would have to raise a request in AdSense by submitting your website URL.

Bottom line, you can't do this with AdMob SDK and you're better off with a banner ad at the bottom. Or you can maybe place an interstitial ad when your user is switching between different html pages or after a certain amount of time.

Related