小编eeg*_*per的帖子

为什么我无法将 firebase 电子邮件密码登录链接到 google 登录?

我已经在我的 Android 应用程序中成功实现了Firebase Google Sign-In,并且运行良好。但是,我希望用户也使用电子邮件和密码登录应用程序。因此,我按照 教程将谷歌登录与电子邮件密码登录链接起来。但是,当我尝试使用以下代码使用电子邮件密码登录时:

firebaseAuth.signInWithEmailAndPassword(email, password)
   .addOnCompleteListener(new OnCompleteListener<AuthResult>()
   {
      @Override
      public void onComplete(@NonNull Task<AuthResult> task)
      {
         if (task.isSuccessful())
         {
             //code to link accounts
         }
         else
         {
             Toast.makeText(context, "SIgn In Error", Toast.LENGTH_SHORT).show();
             System.out.println("SIGN IN: " +  task.getException());
         }
      }
  });
Run Code Online (Sandbox Code Playgroud)

它显示了异常:

com.google.firebase.auth.FirebaseAuthInvalidCredentialsException: The password is invalid or the user does not have a password.
Run Code Online (Sandbox Code Playgroud)

代码有什么问题吗?

android firebase firebase-authentication

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

如何从firestore数据库中的云功能更新多个文档?

我是 firebase 云函数的新手,我想在集合更改特定文档的字段时更新集合username中某些文档的字段。我使用以下代码来做到这一点:postsusersusername

exports.updateProfileUsername = functions.firestore
  .document('users/{userId}')
  .onUpdate((change, context) => 
  {
    const {userId} = context.params;

    var newUsername = change.after.data().username;
    var previousUsername = change.before.data().username;

    if (newUsername.localeCompare(previousUsername) !== 0)
    {
      let postCollectionRef = db.collection('posts');
      let postQuery = postCollectionRef.where('userId', '==', `${userId}`);

      return new Promise((resolve, reject) => 
      {
        updateUsernameDocuments(postQuery, reject, newUsername);
      });
    }
  });

function updateUsernameDocuments(query, reject, newValue) 
  {
    query.get()
      .then((snapshot) => 
      {
        if (snapshot.size === 0) 
        {
          return 0;
        }

        return snapshot.docs.forEach((doc) =>
        {
          doc.ref.update({username : `${newValue}`});
        }); …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions google-cloud-firestore

4
推荐指数
1
解决办法
2525
查看次数

如何更改可绘制资源中的线条长度?

我使用以下 xml 代码来绘制可绘制图像:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape
            android:shape="rectangle" >
            <corners
                android:topLeftRadius="30dp"
                android:topRightRadius="30dp"
                android:bottomLeftRadius="30dp"
                android:bottomRightRadius="30dp" />
            <solid
                 android:color="@color/black" />
            <padding
                 android:left="0dp"
                 android:top="0dp"
                 android:right="0dp"
                 android:bottom="0dp" />
            <size
                 android:width="60dp"
                 android:height="60dp" />
           </shape>
     </item>

     <item>
        <rotate
             android:fromDegrees="45"
             android:toDegrees="45"
             android:pivotX="50%"
             android:pivotY="50%">

            <shape
                android:shape="line">
                <stroke
                      android:width="2dp"
                     android:color="@color/white" />
               </shape>
          </rotate>
     </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

通过上面的代码,我最终得到了这个图像: 在此输入图像描述

现在我必须减少圆中心白线的长度。我已经使用了<size android:height="40dp" /><size android:width="40dp" />就行了,但它没有任何作用。那么,如何减少线路长度呢?

android xml-drawable

3
推荐指数
1
解决办法
1036
查看次数

当应用程序处于后台时,如何从 BroadcastReceiver 的 onReceive() 方法启动活动?

onReceive()我想从BroadcastReceiver 的方法启动一个活动。这是我正在使用的代码:

class TimeReminderReceiver : BroadcastReceiver() {
     override fun onReceive(p0: Context?, p1: Intent?) {
         println("RECEIVED")

         val i = Intent(p0!!, TimeReminderActivity::class.java)
         i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
         p0.startActivity(i)
     }
}
Run Code Online (Sandbox Code Playgroud)

这个问题在 stackoverflow 上有很多答案,我都试过了,但没有一个对我有用。该应用程序只是打印 RECEIVED并保留在那里。logcat 上什么也没有显示,没有例外,什么也没有。我也在 mainfest 中添加了接收器。

<receiver
        android:name=".receivers_and_activities.TimeReminderReceiver" />
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

编辑:

调用广播的代码:

val intent = Intent(this@MainActivity, TimeReminderReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(this@MainActivity, 0, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT)
val am = this@MainActivity.getSystemService(Context.ALARM_SERVICE) as AlarmManager
am.set(AlarmManager.RTC_WAKEUP, calendar.timeInMillis, pendingIntent)
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver kotlin

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