小编use*_*471的帖子

如何在firebase android中添加新数据

这是我在firebase实时数据库中添加新人的逻辑.但是,不是创建新条目,而是使用新数据更新旧数据.

buttonSave.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {


            /*
            new Firebase(Config.FIREBASE_URL)
                    .push()
                    .child("title")
                    .setValue(text.getText().toString());
            */

            Firebase ref = new Firebase(Config.FIREBASE_URL);
            String name = editTextName.getText().toString().trim();
            String address = editTextAddress.getText().toString().trim();

            //Creating Person object
            Person person = new Person();

            //Adding values
            person.setName(name);
            person.setAddress(address);
            ref.child("Person").setValue(person);

        }
    });


    new Firebase(Config.FIREBASE_URL).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            for (DataSnapshot postSnapshot : snapshot.getChildren()) {
                //Getting the data from snapshot
                Person person = postSnapshot.getValue(Person.class);

                //Adding it to a string
                String string = "Name: "+person.getName()+"\nAddress: "+person.getAddress()+"\n\n"; …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-realtime-database

12
推荐指数
1
解决办法
5万
查看次数

Firebase动态链接无法打开应用

我在我的设备上本地开发了一个Android应用程序(app尚未在Android Play商店中).我有以下逻辑来在MainActivity中获得深层链接.

GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, null)
            .addApi(AppInvite.API)
            .build();

    // Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true
    // would automatically launch the deep link if one is found.
    boolean autoLaunchDeepLink = false;
    AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
            .setResultCallback(
                    new ResultCallback<AppInviteInvitationResult>() {
                        @Override
                        public void onResult(@NonNull AppInviteInvitationResult result) {
                            if (result.getStatus().isSuccess()) {
                                // Extract deep link from Intent
                                Intent intent = result.getInvitationIntent();
                                String deepLink = AppInviteReferral.getDeepLink(intent);

                                Toast.makeText(getApplicationContext(), deepLink, Toast.LENGTH_LONG).show();
                                // Handle the deep link. …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-dynamic-links

12
推荐指数
2
解决办法
1万
查看次数

为什么我们不能使用getUid()在firebase身份验证中对后端服务器进行身份验证

在他们提到的这段代码片段(firebase doc)中,不要使用user.getUid()对后端服务器进行身份验证.请改用FirebaseUser.getToken().

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
    // Name, email address, and profile photo Url
    String name = user.getDisplayName();
    String email = user.getEmail();
    Uri photoUrl = user.getPhotoUrl();

    // The user's ID, unique to the Firebase project. Do NOT use this value to
    // authenticate with your backend server, if you have one. Use
    // FirebaseUser.getToken() instead.
    String uid = user.getUid();
}


getUid()    A unique user ID, intended as the user's unique key across all providers.   
getToken() …
Run Code Online (Sandbox Code Playgroud)

firebase-authentication

6
推荐指数
1
解决办法
1784
查看次数