我想从firebase数据库中读取特定数据.我目前正在做的是这里.
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference myRef = database.child("profiles/");
myRef.child(phoneNo).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
user = dataSnapshot.getValue(User.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {}
});
Run Code Online (Sandbox Code Playgroud)
写入DB的方法
public void writeToDBProfiles(Object data,String phoneNo) {
DatabaseReference database = FirebaseDatabase.getInstance().getReference();
DatabaseReference myRef = database.child("profiles/" + phoneNo);
myRef.setValue(data);
}
Run Code Online (Sandbox Code Playgroud)
但它返回null ...任何帮助将不胜感激.
我刚开始使用Android,我正在寻找使用Google Firebase进行Google登录.不幸的是我无法导入
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
Cannot resolve symbol Auth
Cannot resolve symbol GoogleSignInResult
Run Code Online (Sandbox Code Playgroud)
我的项目build.gradle看起来像
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
Run Code Online (Sandbox Code Playgroud)
我的模块build.gradle看起来像
apply plugin: 'com.google.gms.google-services'
.......
.......
.......
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
Run Code Online (Sandbox Code Playgroud)
以下是错误
Error:(229, 29) error: cannot find symbol variable disconnect_button
Error:(227, 29) error: cannot find symbol variable sign_out_button
Error:(225, 22) error: cannot find symbol variable …Run Code Online (Sandbox Code Playgroud)