private void displayImage() {
StorageReference storageRef = mFirebaseStorage.getReferenceFromUrl("gs://myfirebase-332e8.appspot.com/3.jpg");
storageRef.getBytes(Long.MAX_VALUE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
Log.d(TAG, "getBytes Success");
// Use the bytes to display the image
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
ImageView iv = (ImageView)findViewById(R.id.imageView);
iv.setImageBitmap(bmp);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.d(TAG, "getBytes Failed");
}
});
}
private FirebaseRemoteConfig mFirebaseRemoteConfig;
private ActivityMainBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() == null) {
finish();
return;
}
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(3600) // For development only not for production!, default is 12 hours
.build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);
mFirebaseRemoteConfig.setDefaultsAsync(R.xml.remote_config_defaults);
}
<?xml version="1.0" encoding="utf-8"?>
<defaultsMap xmlns:android="http://schemas.android.com/apk/res/android">
<entry>
<key>your_price</key>
<value>100</value>
</entry>
<entry>
<key>cheat_enabled</key>
<value>false</value>
</entry>
</defaultsMap>
public void onFetchButton(View v) {
mFirebaseRemoteConfig.fetchAndActivate()
.addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
@Override
public void onComplete(@NonNull Task<Boolean> task) {
if (task.isSuccessful()) {
boolean updated = task.getResult();
Log.d(TAG, "Config params updated: " + updated);
} else {
Log.d(TAG, "Fetch failed");
}
displayConfig(); // 가져온 설정 읽기(다음 슬라이드)
}
});
}
private void displayConfig() {
boolean cheat_enabled = mFirebaseRemoteConfig.getBoolean("cheat_enabled");
binding.textViewCheat.setText("cheat_enabled=" + cheat_enabled);
long price = mFirebaseRemoteConfig.getLong("your_price");
binding.textViewPrice.setText("your_price is " + price);
}