我的日志显示9/com.fishexpert E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaaacb680
我已经尝试过将这些代码用于多语言。但不幸的是,它不支持23以下的API,但可以支持API 24至29
@SuppressWarnings(value = "deprication")
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void setLocale(String localeName) {
if (!localeName.equals(currentLanguage)) {
myLocale = new Locale(localeName);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
conf.setLocale(myLocale);
res.updateConfiguration(conf, res.getDisplayMetrics());
Intent refresh = new Intent(Language_act.this,StartingActivity.class);
refresh.putExtra(currentLang, localeName);
finish();
startActivity(refresh);
}
else{
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
Intent refresh = new Intent(Language_act.this,StartingActivity.class);
refresh.putExtra(currentLang, localeName);
finish();
startActivity(refresh);
}
} else {
Toast.makeText(Language_act.this, "Language already selected!", Toast.LENGTH_SHORT).show();
}
}
public void onBackPressed() {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
System.exit(0);
}