本文整理匯總了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);
}