【问题标题】:How can I display time and date in notification?如何在通知中显示时间和日期?
【发布时间】:2018-02-28 00:45:36
【问题描述】:

如何向用户发送包含时间和日期的通知?用户完成预约后,它将向用户发送通知,让用户知道日期和时间。任何人都可以帮助我

这是我在 firebase 中存储的日期和时间数据

私有 TextView mDate;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_user_information);
    mDate = (TextView) findViewById(R.id.tvdate);

    //declare the database reference object. This is what we use to access the database.
    //NOTE: Unless you are signed in, this will not be useable.
    mAuth = FirebaseAuth.getInstance();
    mFirebaseDatabase = FirebaseDatabase.getInstance();
    myRef = mFirebaseDatabase.getReference();
    buttonBack = (Button) findViewById(R.id.btnBack);
    final FirebaseUser user = mAuth.getCurrentUser();
    userID = user.getUid();


    buttonBack.setOnClickListener(this);


    // Read from the database
    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mDate.setText(dataSnapshot.child(userID).child("Appointment").child("date").getValue(String.class));

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

【问题讨论】:

  • 可以使用 textview 和 string 显示
  • 如何使用textview?我已经上传了我的代码,但是这段代码出错了我尝试了很多方法,但仍然无法得到它。
  • 嗨 Bleach,在 Udacity 上开始一个基本的 Android 免费课程来学习使用它
  • 我已经完成了通知部分,但无法显示我的数据。

标签: android firebase firebase-realtime-database android-push-notification


【解决方案1】:

你需要阅读Firebase Cloud Messaging for Android

如果你想管理之前的数据,Read cloud functions 也是。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    • 2019-04-24
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    相关资源
    最近更新 更多