在Android Studio的Firebase中输入数据时如何发送/接收通知

时间:2019-07-28 06:49:44

标签: java android firebase notifications

我正在将数据存储在Firebase数据库中。当我更新Firebase数据库时,我想在Android设备上收到通知。当我单击通知时,应将我重定向到相应的活动页面。请帮忙??

private void lecturedetails() {

        databaseReference = FirebaseDatabase.getInstance().getReference("Lecture Details");

        String date = enterdate.getText().toString().trim();
        String subjectname = entersubjectname.getText().toString().trim();
        String time = entertime.getText().toString().trim();


        if (TextUtils.isEmpty(date)) {

            Toast.makeText(this, "Enter Date", Toast.LENGTH_SHORT).show();
            return;
        }
        else if (TextUtils.isEmpty(subjectname)) {

            Toast.makeText(this, "Enter Subject", Toast.LENGTH_SHORT).show();
            return;
        }
        else if (TextUtils.isEmpty(time)) {

            Toast.makeText(this, "Enter Time", Toast.LENGTH_SHORT).show();
            return;
        }
        else {
            String id =databaseReference.push().getKey();
            lectureinfo lectureinfo = new lectureinfo(date, subjectname,time);
            databaseReference.child(id).setValue(lectureinfo);
            Toast.makeText(this, "Data Added", Toast.LENGTH_SHORT).show();
        }
    }

0 个答案:

没有答案