Skip to content

Instantly share code, notes, and snippets.

@furyu-araki
Last active June 14, 2016 15:19
Show Gist options
  • Save furyu-araki/ca72052aba6831fcb4bed54e9cb73168 to your computer and use it in GitHub Desktop.
Save furyu-araki/ca72052aba6831fcb4bed54e9cb73168 to your computer and use it in GitHub Desktop.
init Firebase
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
/**
* Created by taku on 16/05/29.
*/
public class SplashActivity extends AppCompatActivity {
private static final String TAG = SplashActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
remoteConfig.setDefaults(R.xml.remote_config_defaults);
remoteConfig.fetch(0).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "Fetch Succeeded");
remoteConfig.activateFetched();
} else {
Log.e(TAG, "Fetch failed", task.getException());
}
String pattern = remoteConfig.getString("pattern");
MyApplication.getAnalytics(SplashActivity.this).setUserProperty("test_pattern", pattern);
startActivity(MainActivity.createIntent(SplashActivity.this));
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment