像firebase实时数据库一样,我不想在firestore集合中存储空/空值。所以我如何从firestore集合中跳过或删除空字段 
下面的功能将数据保存到firestore
private void saveTofireStore(String path, User userObject,Class<?> classType){
FirebaseFirestore db = FirebaseFirestore.getInstance();
documentReference = db.document(path);
Log.d(TAG,""+documentReference.getPath());
documentReference
.set(userObject)
.addOnCompleteListener(task -> {
if (task.isSuccessful()){
appearanceMutableLiveData.setValue(task.getResult());
}else {
appearanceMutableLiveData.setValue(null);
}
});
}
Run Code Online (Sandbox Code Playgroud) 当使用 Firebase 身份验证成功创建新用户帐户后,我尝试发出第二个请求以在 Firebase 数据库中创建他的个人资料(姓名、电子邮件和电话),但如果第二个请求失败,我将拥有一个没有个人资料的用户这种情况应该是不可能的,因为他在登录时将无法编辑他的个人资料,所以目前我正在 Firebase Auth 中删除这个最近创建的用户,以允许他重试创建,但它不会解决问题,因为删除请求也可能失败。在 Firebase 中处理事务的最佳方式是什么,是成功创建用户及其个人资料还是全部都不创建?
private void attemptToCreateAccount(final Credentials cred) {
getCompositeDisposable().add(
getAuthService().createAccount(cred)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribeWith(new DisposableSingleObserver<User>() {
@Override
public void onSuccess(User user) {
addUserProfileToDatabase(user.getEmail(), user.getUserUid(), cred.getUsername(), cred.getPassword());
}
@Override
public void onError(Throwable e) {
getView().showMessage(e.toString());
}
})
);
}
--------------------------
private void addUserProfileToDatabase(final String email, final String userUid, final String name, final String password) {
final Profile profile = new Profile("", "", "", email, "", name);
getCompositeDisposable().add(
getDatabaseSource().createNewProfileToUser(userUid, profile)
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribeWith(new DisposableCompletableObserver(){
@Override …Run Code Online (Sandbox Code Playgroud) java android firebase-authentication firebase-realtime-database
我花了一整天的时间来弄清楚为什么我的自定义通知没有显示出来。最后,是约束布局的问题。当我尝试使用约束布局构建 custom_notification.xml 时,通知不会显示,但如果我更改为线性布局,则通知有效。谁能告诉我为什么会这样?
custom_notitication.xml 具有线性布局(此布局有效)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Button"
<Button
android:layout_weight="1"
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Button"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
带有约束布局的 custom_notitication.xml(这不起作用)
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Button"
app:layout_constraintEnd_toStartOf="@+id/button2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:layout_weight="1"
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button"
/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
和 kotlin 代码
fun getNotification(context: Context): Notification {
val mNotificationManager1: NotificationManager?
val notification: Notification
mNotificationManager1 = context.getSystemService(Context.NOTIFICATION_SERVICE) as …Run Code Online (Sandbox Code Playgroud) 我有一个Java界面:
public interface NonHindiQurary {
void onNonHindiQueryReceived(String Query);
}
Run Code Online (Sandbox Code Playgroud)
我想在Kotlin类上实现它:
class MainActivity : AppCompatActivity() {...}
Run Code Online (Sandbox Code Playgroud)
问:我该怎么办?
我在我的Android应用程序中获取Thu, 25 Aug 2016 08:59:00 GMT此RFC 1123格式的日期时间.我需要转换为当地时间.