{"id":17472380,"url":"https://github.com/pranavpandey/dynamic-ads","last_synced_at":"2025-06-11T05:32:56.746Z","repository":{"id":53266574,"uuid":"510079103","full_name":"pranavpandey/dynamic-ads","owner":"pranavpandey","description":"Show GDPR-compliant ads via Google AdMob on Android.","archived":false,"fork":false,"pushed_at":"2025-03-05T19:31:19.000Z","size":1171,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T11:08:05.324Z","etag":null,"topics":["admob","ads","android","banner","google","interstitial","library","native"],"latest_commit_sha":null,"homepage":"https://dynamic.pranavpandey.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pranavpandey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"pranavpandey","patreon":"pranavpandey","open_collective":"pranavpandeydev","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/pranavpandeydev"]}},"created_at":"2022-07-03T16:38:56.000Z","updated_at":"2025-03-05T19:31:23.000Z","dependencies_parsed_at":"2023-12-19T01:02:17.021Z","dependency_job_id":"5a2465a6-7281-467c-91f8-7ef8d331323a","html_url":"https://github.com/pranavpandey/dynamic-ads","commit_stats":{"total_commits":57,"total_committers":1,"mean_commits":57.0,"dds":0.0,"last_synced_commit":"dd0e51d7dc73fc492e4619a144884750088a56d6"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-ads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-ads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-ads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-ads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranavpandey","download_url":"https://codeload.github.com/pranavpandey/dynamic-ads/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-ads/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259207693,"owners_count":22821742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admob","ads","android","banner","google","interstitial","library","native"],"created_at":"2024-10-18T17:09:09.993Z","updated_at":"2025-06-11T05:32:56.711Z","avatar_url":"https://github.com/pranavpandey.png","language":"Java","funding_links":["https://github.com/sponsors/pranavpandey","https://patreon.com/pranavpandey","https://opencollective.com/pranavpandeydev","paypal.me/pranavpandeydev","https://paypal.me/pranavpandeydev"],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./graphics/icon.png\" height=\"160\"\u003e\n\n# Dynamic Ads\n\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Release](https://img.shields.io/maven-central/v/com.pranavpandey.android/dynamic-ads)](https://search.maven.org/artifact/com.pranavpandey.android/dynamic-ads)\n\n**A GDPR-compliant library to show ads via Google AdMob on Android 4.1 (API 16) and above.**\n\n\u003e [!IMPORTANT]\n\u003e It uses [AndroidX][androidx] so, first [migrate][androidx-migrate] your project to AndroidX.\n\u003cbr/\u003eIt is dependent on Java 8 due to the dependency on [Dynamic Utils][dynamic-utils].\n\u003cbr/\u003eSince v1.3.0, it is targeting Java 17 to provide maximum compatibility.\n\u003cbr/\u003eSince v1.4.0, the minimum SDK is Android 4.4 (API 19) to comply with the latest policies.\n\n---\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Initialize](#initialize)\n    - [Host](#host)\n    - [Consent](#consent)\n    - [Dynamic Ad](#dynamic-ad)\n    - [Sponsor](#sponsor)\n    - [Dependency](#dependency)\n- [License](#license)\n\n---\n\n## Installation\n\nIt can be installed by adding the following dependency to your `build.gradle` file:\n\n```groovy\ndependencies {\n  // For AndroidX enabled projects.\n  implementation 'com.pranavpandey.android:dynamic-ads:1.4.0'\n}\n```\n\n---\n\n## Usage\n\nIt supports various ad formats as mentioned in the official Google [AdMob guide][admob guide].\nPlease [sign in][admob sign-in] to or [sign up][admob sign-up] for an AdMob account first.\n\n\u003e For a complete reference, please read the [documentation][documentation].\n\n### Initialize\n\n`DynamicAds` must be initialized once before accessing its methods. Dynamic ad formats do that\nautomatically before doing any operations but it should be done manually if anything has to be\ndone before.\n\n```java\n// Initialize with application context.\nDynamicAds.initializeInstance(applicationContext);\n```\n\n### Host\n\n`BaseAdListener` is the base class that an ad host like an `activity` must implement.\nIt guides the internal framework about how and when an ad should be displayed.\n\n\u003e It is used to create various factory [listeners][ad listeners] to show different ad formats\nand they should be implemented according to the requirements.\n\n### Consent\n\nIt provides built-in support for the consent form required to be shown in `GDPR` regions before\ninitializing any of the ads. It uses [User Messaging Platform (UMP)][admob ump] underneath to do\nall the heavy lifting and provides a simple yet customizable interface.\n\n```java\n// Show a consent form.\nDynamicAds.getInstance()\n        // Set the consent request parameters required to load the consent information.\n        .setConsentRequestParameters(consentRequestParameters)\n        // Try to show the consent form if available\n        .showConsentForm(dynamicAdListener);\n\n// Other methods related to the consent form.\nDynamicAds.getInstance()\n        // Checks whether a consent information is available.\n        .isConsentInformationAvailable()\n        // Checks whether a consent form is available.\n        .isConsentFormAvailable()\n        // Checks whether a consent form is visible to the user.\n        .isConsentFormVisible()\n        // Checks whether a consent is required from the user.\n        .isConsentRequired()\n        // Returns the status of the consent information.\n        .getConsetStatus();\n```\n\n### Dynamic Ad\n\n`DynamicAd` is the base class to implement various [ad formats][ad formats].\n\n```java\n/**\n * An activity to host a dynamic ad.\n */\npublic AdHostActivity extends Activity implements BannerAdListener {\n    \n    ...\n        \n    // Initialize the banner ad.\n    mDynamicBannerAd = new DynamicBannerAd(AD_UNIT_ID, this) {\n        ...\n    \n        @Override\n        public @NonNull AdRequest getAdRequest() {\n            return new AdRequest.Builder().build();\n        }\n    \n        @Override\n        public @NonNull RequestConfiguration getAdRequestConfigurations() {\n            return MobileAds.getRequestConfiguration().toBuilder()\n                    .setTagForChildDirectedTreatment(\n                    RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)\n                    .setTagForUnderAgeOfConsent(\n                    RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)\n                    .setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)\n                    .build();\n        }\n          \n        ...\n    };\n\n    @Override\n    public @NonNull Context getAdContext() {\n        // Return context for this host.\n        return this;\n    }\n\n    @Override\n    public boolean isAdEnabled() {\n        // Ads are enabled for this host.\n        return true;\n    }\n    \n    ...\n\n    @Override\n    public void onAdDisplay(@NonNull AdView adView) {\n        // Add the ad view to a container to make it visible.\n        DynamicViewUtils.addView(container, adView, true);\n    }\n    \n    ...\n\n    @Override\n    public void onResume() {\n        super.onResume();\n\n        // Resume a dynamic ad if supported.\n        DynamicAds.onAdResume(mDynamicBannerAd);\n    }\n\n    @Override\n    public void onPause() {\n        // Pause a dynamic ad if supported.\n        DynamicAds.onAdPause(mDynamicBannerAd);\n        super.onPause();\n    }\n\n    @Override\n    public void onDestroy() {\n        // Destroy a dynamic ad if supported.\n        DynamicAds.onAdDestroy(mDynamicBannerAd);\n        super.onDestroy();\n    }\n}\n```\n\n### Sponsor\n\nPlease become a [sponsor][sponsor] to get a detailed guide and priority support.\n\n### Dependency\n\nIt depends on the [dynamic-utils][dynamic-utils] to perform various internal operations. \nSo, its functions can also be used to perform other useful operations.\n\n---\n\n## Author\n\nPranav Pandey\n\n[![GitHub](https://img.shields.io/github/followers/pranavpandey?label=GitHub\u0026style=social)](https://github.com/pranavpandey)\n[![Follow on Twitter](https://img.shields.io/twitter/follow/pranavpandeydev?label=Follow\u0026style=social)](https://twitter.com/intent/follow?screen_name=pranavpandeydev)\n[![Donate via PayPal](https://img.shields.io/static/v1?label=Donate\u0026message=PayPal\u0026color=blue)](https://paypal.me/pranavpandeydev)\n\n---\n\n## License\n\n    Copyright 2022-2024 Pranav Pandey\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n[androidx]: https://developer.android.com/jetpack/androidx\n[androidx-migrate]: https://developer.android.com/jetpack/androidx/migrate\n[documentation]: https://pranavpandey.github.io/dynamic-ads\n[sponsor]: https://github.com/sponsors/pranavpandey\n[admob ump]: https://developers.google.com/admob/ump/android/quick-start\n[admob sign-in]: https://admob.google.com/home\n[admob sign-up]: https://support.google.com/admob/answer/7356219\n[admob guide]: https://developers.google.com/admob/android/quick-start\n[ad listeners]: https://github.com/pranavpandey/dynamic-ads/blob/main/dynamic-ads/src/main/java/com/pranavpandey/android/dynamic/ads/listener/factory\n[ad formats]: https://github.com/pranavpandey/dynamic-ads/blob/main/dynamic-ads/src/main/java/com/pranavpandey/android/dynamic/ads/factory\n[dynamic-utils]: https://github.com/pranavpandey/dynamic-utils\n[dynamic-support]: https://github.com/pranavpandey/dynamic-support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-ads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranavpandey%2Fdynamic-ads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-ads/lists"}