Add api 21 check to LocalizationChannel.java (#7967)

This commit is contained in:
Gary Qian 2019-02-26 11:33:07 -08:00 committed by GitHub
parent 113b91fe82
commit 4434a39c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
package io.flutter.embedding.engine.systemchannels;
import android.os.Build;
import android.support.annotation.NonNull;
import java.util.ArrayList;
@ -35,7 +36,8 @@ public class LocalizationChannel {
for (Locale locale : locales) {
data.add(locale.getLanguage());
data.add(locale.getCountry());
data.add(locale.getScript());
// locale.getScript() was added in API 21.
data.add(Build.VERSION.SDK_INT >= 21 ? locale.getScript() : "");
data.add(locale.getVariant());
}
channel.invokeMethod("setLocale", data);