Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseError not resolved

I'm writing an app that updates to Firebase but I can't write the oncancelled function because it cannot resolve symbol FirebaseError.

My code below:

package com.test.myapplication;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

import static com.test.myapplication.R.id.radioButton5;
import static com.test.myapplication.R.id.radioButton6;
import static com.test.myapplication.R.id.radioButton8;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;

public class OfficialDetail extends AppCompatActivity {

TextView textViewStreet;
TextView textViewLat;
TextView textViewLong;
TextView textViewDescription;
TextView textViewSeverity;
TextView textViewSize;
TextView textViewEmail;
RadioButton RadioButton5;
RadioButton RadioButton6;
RadioButton RadioButton8;
DatabaseReference mRef;
DatabaseReference dRef;

ArrayList<Report> reportArrayList;

Report value;
ListView mListView;


ImageView imgView;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_item_detail);
    RadioButton5 = (RadioButton)findViewById(radioButton5);
    RadioButton6 = (RadioButton)findViewById(radioButton6);
    RadioButton8 = (RadioButton)findViewById(radioButton8);
    Intent intent = getIntent();

    initialize();


    if(intent!=null) {

        textViewStreet.setText(intent.getStringExtra("street_of"));
        textViewLat.setText(intent.getStringExtra("lat_of"));
        textViewLong.setText(intent.getStringExtra("long_of"));
        textViewDescription.setText(intent.getStringExtra("descrip_of"));
        textViewSeverity.setText(intent.getStringExtra("severity_of"));
        textViewSize.setText(intent.getStringExtra("size_of"));

        if(intent.getStringExtra("Off").equals("Official")){
            RadioButton5.setEnabled(false);
            RadioButton8.setEnabled(false);
        }else{
            RadioButton5.setEnabled(false);
            RadioButton6.setEnabled(false);
        }
        if (RadioButton6.isChecked()){
            reportArrayList = new ArrayList<>();


            dRef = FirebaseDatabase.getInstance().getReference();
            mRef = dRef.child("report");
            Query qRef;
            qRef = dRef.orderByChild("Status").equalTo("still_there");

            qRef.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot tasksSnapshot) {
                    for (DataSnapshot snapshot: tasksSnapshot.getChildren()) {
                        snapshot.getRef().child("Status").setValue("removal_confirmed");
                    }
                }
                @Override
                public void onCancelled(**FirebaseError**  firebaseError) {
                    System.out.println("The read failed: " + firebaseError.getMessage());
                }
            });
        }
        byte[] decodedString = Base64.decode(intent.getStringExtra("img_of"), Base64.DEFAULT);
        Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        imgView.setImageBitmap(decodedByte);


    }

}

private void initialize(){


    textViewStreet = (TextView) findViewById(R.id.textView22);
    imgView = (ImageView) findViewById(R.id.imageView);
    textViewDescription = (TextView) findViewById(R.id.item_detail);
    textViewSeverity = (TextView) findViewById(R.id.textView24);
    textViewSize = (TextView) findViewById(R.id.textView26);
    textViewLat = (TextView) findViewById(R.id.textView13);
    textViewLong = (TextView) findViewById(R.id.textView17);

}
}

Is there an import statement I'm missing? How can I resolve this?

like image 862
Nima Avatar asked Sep 10 '25 23:09

Nima


1 Answers

Try changing the FirebaseError class with DatabaseError class.

I had the same issue and what I did was just removed all the method codes and allowed the Android Studio to create the method definition itself. Then the FirebaseError was replaced with DatabaseError automatically.

like image 68
Febin Mathew Avatar answered Sep 13 '25 13:09

Febin Mathew