當前位置: 首頁>>代碼示例>>Java>>正文


Java FirebaseDatabase.getReference方法代碼示例

本文整理匯總了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");
                       }
                   }
               }
            );
}
 
開發者ID:sindhu732,項目名稱:instagram_clone,代碼行數:21,代碼來源:AccountActivity.java

示例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();
}
 
開發者ID:YoungPeacock,項目名稱:FantaF1,代碼行數:26,代碼來源:LoginActivity.java

示例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);
    }
}
 
開發者ID:projets2017cl,項目名稱:vc,代碼行數:11,代碼來源:Operation_TypeService.java

示例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();
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:10,代碼來源:FirebaseDatabaseTestIT.java

示例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");
            }
        });
    }
 
開發者ID:codingdojoangola,項目名稱:cda-app,代碼行數:34,代碼來源:ChatActivity.java

示例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);
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:10,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:projets2017cl,項目名稱:vc,代碼行數:11,代碼來源:ProductService.java

示例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());
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:8,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:projets2017cl,項目名稱:vc,代碼行數:11,代碼來源:PersonService.java

示例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);
    }
}
 
開發者ID:projets2017cl,項目名稱:vc,代碼行數:11,代碼來源:LocalizationService.java

示例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);
    }
}
 
開發者ID:projets2017cl,項目名稱:vc,代碼行數:11,代碼來源:OperationService.java

示例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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:45,代碼來源:ShutdownExample.java

示例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);
}
 
開發者ID:Tritium-3h,項目名稱:SimonSaysAndroid,代碼行數:7,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:iamjaspreetsingh,項目名稱:TrackPlan-app,代碼行數:23,代碼來源:ConnectActivity.java

示例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);









}
 
開發者ID:iamjaspreetsingh,項目名稱:TrackPlan-app,代碼行數:18,代碼來源:ListViewAdteach.java


注:本文中的com.google.firebase.database.FirebaseDatabase.getReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。