当前位置: 首页>>代码示例>>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;未经允许,请勿转载。