Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add includecode snippets for Android adaptive banner getAdSize #767

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ private void initializeMobileAdsSdk() {
.start();
}

// [START get_ad_size]
// Get the ad size with screen width.
public AdSize getAdSize() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Expand All @@ -218,4 +219,5 @@ public AdSize getAdSize() {
int adWidth = (int) (adWidthPixels / density);
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth);
}
// [END get_ad_size]
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private void initializeMobileAdsSdk() {

// [END request_ads]

// [START get_ad_size]
// Get the ad size with screen width.
public AdSize getAdSize() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Expand All @@ -227,4 +228,5 @@ public AdSize getAdSize() {
int adWidth = (int) (adWidthPixels / density);
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth);
}
// [END get_ad_size]
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MyActivity : AppCompatActivity() {
private lateinit var binding: ActivityMyBinding
private lateinit var googleMobileAdsConsentManager: GoogleMobileAdsConsentManager

// [START get_ad_size]
// Get the ad size with screen width.
private val adSize: AdSize
get() {
Expand All @@ -61,6 +62,8 @@ class MyActivity : AppCompatActivity() {
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
}

// [END get_ad_size]

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMyBinding.inflate(layoutInflater)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var googleMobileAdsConsentManager: GoogleMobileAdsConsentManager

// [START get_ad_size]
// Get the ad size with screen width.
private val adSize: AdSize
get() {
Expand All @@ -61,6 +62,8 @@ class MainActivity : AppCompatActivity() {
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
}

// [END get_ad_size]

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
Expand Down
Loading