mirror of
https://github.com/androidx/media.git
synced 2025-05-04 22:20:47 +08:00
Pass full locale code to IMA
IMA can now handle the full locale code properly. PiperOrigin-RevId: 354528700
This commit is contained in:
parent
07e8860084
commit
e41d042863
@ -60,7 +60,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -700,7 +699,7 @@ public final class ImaAdsLoader implements Player.EventListener, AdsLoader {
|
||||
@Override
|
||||
public ImaSdkSettings createImaSdkSettings() {
|
||||
ImaSdkSettings settings = ImaSdkFactory.getInstance().createImaSdkSettings();
|
||||
settings.setLanguage(getImaLanguageCodeForDefaultLocale());
|
||||
settings.setLanguage(Util.getSystemLanguageCodes()[0]);
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -742,17 +741,5 @@ public final class ImaAdsLoader implements Player.EventListener, AdsLoader {
|
||||
return ImaSdkFactory.getInstance()
|
||||
.createAdsLoader(context, imaSdkSettings, adDisplayContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a language code that's suitable for passing to {@link ImaSdkSettings#setLanguage} and
|
||||
* corresponds to the device's {@link Locale#getDefault() default Locale}. IMA will fall back to
|
||||
* its default language code ("en") if the value returned is unsupported.
|
||||
*/
|
||||
// TODO: It may be possible to define a better mapping onto IMA's supported language codes. See:
|
||||
// https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/localization.
|
||||
// [Internal ref: b/174042000] will help if implemented.
|
||||
private static String getImaLanguageCodeForDefaultLocale() {
|
||||
return Util.splitAtFirst(Util.getSystemLanguageCodes()[0], "-")[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user