我正在尝试在我的应用程序中使用 firebase 远程配置功能。但我收到错误“无法解析方法'getBaseContext()'”。我的课程扩展了 BaseAdapter,如下所示。我仅限于使用方法,请帮助。
public class CustomAdapter_new extends BaseAdapter {
.....
......
........
private void initRemoteConfig() {
mRemoteConfig = FirebaseRemoteConfig.getInstance();
Resources res = context.getResources();
HashMap<String, Object> defaults = new HashMap<>();
defaults.put("claimStatusEnquiry", context.getResources().getString(R.string.claimStatusEnquiry)); defaults.put("locateYourPfOffice", context.getResources().getString(R.string.locateYourOffice));
defaults.put("faq", context.getResources().getString(R.string.faq));
mRemoteConfig.setDefaults(defaults);
FirebaseRemoteConfigSettings remoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(true)
.build();
mRemoteConfig.setConfigSettings(remoteConfigSettings);
fetchRemoteConfigValues();
}
private void fetchRemoteConfigValues() {
long cacheExpiration = 600;
//expire the cache immediately for development mode.
if (mRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
mRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
if (task.isSuccessful()) {
// task successful. Activate the fetched data
mRemoteConfig.activateFetched();
} else {
//task failed
Toast.makeText(getBaseContext(), "Please Connect To Internet!!", Toast.LENGTH_SHORT).show();
}
}
});
}
}