本文整理汇总了Java中com.google.firebase.database.FirebaseDatabase.getReference方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseDatabase.getReference方法的具体用法?Java FirebaseDatabase.getReference怎么用?Java FirebaseDatabase.getReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.database.FirebaseDatabase
的用法示例。
在下文中一共展示了FirebaseDatabase.getReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUserProfile
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
private void createUserProfile(String name, String uid, String email) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
User user = new User(uid, name, email);
myRef.child("users").child(uid).setValue(user);
FirebaseUser currentUser = mAuth.getCurrentUser();
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName(name).build();
currentUser.updateProfile(profileUpdates)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()) {
Log.d(TAG, "User display_name added");
}
}
}
);
}
示例2: setContent
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
private void setContent() {
setContentView(R.layout.activity_login);
screen = (RelativeLayout)findViewById(R.id.rl);
ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
TransitionDrawable trans = new TransitionDrawable(color);
screen.setBackgroundDrawable(trans);
trans.startTransition(1800);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
.enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
mAuth = FirebaseAuth.getInstance();
FirebaseDatabase database = FirebaseDatabase.getInstance();
root= database.getReference("room_names");
loadRooms();
new CountDownTimer(2500, 1000) {
public void onTick(long millisUntilDone) { }
public void onFinish() {
currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
}.start();
}
示例3: Operation_typeService
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
Operation_typeService() {
try {
this.test = new FireBase_DataBase();
FirebaseDatabase database = FirebaseDatabase.getInstance();
ref = database.getReference("");
Operation_typeRef = ref.child("Operation_type");
} catch (FileNotFoundException ex) {
Logger.getLogger(Operation_typeService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例4: testSetValue
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Test
public void testSetValue() throws InterruptedException, ExecutionException, TimeoutException,
TestFailure {
FirebaseDatabase db = FirebaseDatabase.getInstance(masterApp);
DatabaseReference ref = db.getReference("testSetValue");
ref.setValueAsync("foo").get(TestUtils.TEST_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
ReadFuture readFuture = ReadFuture.untilEquals(ref, "foo");
readFuture.timedWait();
}
示例5: verifyPresence
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
public void verifyPresence(){
final FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference myConnectionsRef = database.getReference().child("user").child(userID).child("status");
final DatabaseReference lastOnlineRef = database.getReference().child("user").child(userID).child("lastOnline");
final DatabaseReference connectedRef = database.getReference(".info/connected");
connectedRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
boolean connected = snapshot.getValue(Boolean.class);
if (connected) {
DatabaseReference con = myConnectionsRef.push();
// when this device disconnects, remove it
con.onDisconnect().removeValue();
// when I disconnect, update the last time I was seen online
lastOnlineRef.onDisconnect().setValue(ServerValue.TIMESTAMP);
// add this device to my connections list
// this value could contain info about the device or a timestamp too
//con.setValue(Boolean.TRUE);
con.setValue(Boolean.TRUE);
}
}
@Override
public void onCancelled(DatabaseError error) {
System.err.println("Listener was cancelled at .info/connected");
}
});
}
示例6: onResume
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@Override
public void onResume(){
super.onResume();
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser mUser = mAuth.getCurrentUser();
String uid = mUser.getUid();
topRef = dbRef.getReference(uid);
}
示例7: ProductService
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
ProductService() {
try {
this.test = new FireBase_DataBase();
FirebaseDatabase database = FirebaseDatabase.getInstance();
ref = database.getReference("");
ProductRef = ref.child("Product");
} catch (FileNotFoundException ex) {
Logger.getLogger(ProductService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例8: save
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
@OnClick(R.id.save_button)
public void save() {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue(dataEditText.getText().toString());
}
示例9: PersonService
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
PersonService() {
try {
this.test = new FireBase_DataBase();
FirebaseDatabase database = FirebaseDatabase.getInstance();
ref = database.getReference("");
PersonRef = ref.child("Person");
} catch (FileNotFoundException ex) {
Logger.getLogger(PersonService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例10: LocalizationService
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
LocalizationService() {
try {
this.test = new FireBase_DataBase();
FirebaseDatabase database = FirebaseDatabase.getInstance();
ref = database.getReference("");
LocalizationRef = ref.child("Localization");
} catch (FileNotFoundException ex) {
Logger.getLogger(LocalizationService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例11: OperationService
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
OperationService() {
try {
this.test = new FireBase_DataBase();
FirebaseDatabase database = FirebaseDatabase.getInstance();
ref = database.getReference("");
OperationRef = ref.child("Operation");
} catch (FileNotFoundException ex) {
Logger.getLogger(OperationService.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例12: main
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
public static void main(String[] args) {
final Semaphore shutdownLatch = new Semaphore(0);
FirebaseApp app =
FirebaseApp.initializeApp(
new FirebaseOptions.Builder()
.setDatabaseUrl("https://admin-java-sdk.firebaseio.com")
.build());
FirebaseDatabase db = FirebaseDatabase.getInstance(app);
db.setLogLevel(Level.DEBUG);
DatabaseReference ref = db.getReference();
ValueEventListener listener =
ref.child("shutdown")
.addValueEventListener(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
Boolean shouldShutdown = snapshot.getValue(Boolean.class);
if (shouldShutdown != null && shouldShutdown) {
System.out.println("Should shut down");
shutdownLatch.release(1);
} else {
System.out.println("Not shutting down: " + shouldShutdown);
}
}
@Override
public void onCancelled(DatabaseError error) {
System.err.println("Shouldn't happen");
}
});
try {
// Keeps us running until we receive the notification to shut down
shutdownLatch.acquire(1);
ref.child("shutdown").removeEventListener(listener);
db.goOffline();
System.out.println("Done, should exit");
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
示例13: sendButtonEventToFirebase
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
public void sendButtonEventToFirebase(int btnIdx,Long counter) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference keyRef = database.getReference(DB_REF_KEY);
keyRef.setValue(new SimonEvent(mButtonLabels[btnIdx],counter));
playSound(btnIdx);
}
示例14: justgo
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
void justgo() {
final Switch discover = (Switch) findViewById(R.id.switch3);
final FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference myRef = database.getReference("user");
DatabaseReference myRef1 = database.getReference("user").child(usernamee);
myRef1.child("name").setValue(mynaam);
myRef1.child("percent").setValue(MainActivity.percentagesending);
SharedPreferences sp2 = getSharedPreferences("discovery", Activity.MODE_PRIVATE);
int myvalue2 = sp2.getInt("1100", 1);
if (myvalue2 == 1) {
myRef1.child("disc").setValue("1");
} else if (myvalue2 == 0)
myRef1.child("disc").setValue("0");
finish();
}
示例15: takeatt
import com.google.firebase.database.FirebaseDatabase; //导入方法依赖的package包/类
void takeatt(String i,String subclass)
{
FirebaseDatabase database = MainteachersActivity.database;
DatabaseReference myRef = database.getReference("Colleges");
DatabaseReference myRef1 = database.getReference("Colleges").child(MainteachersActivity.colname).child(subclass);
myRef1.child("Take").setValue(i);
}