I want to build a method that returns a child value in FireBase. I tried to do something like this:
public String getMessage(){
You can follow this link https://youtu.be/LVaIArVY52U
Firebase database is quite slow when retrieving the data so to make the application wait for the process to complete you can follow this
Create a new class Ex. Firebasedata.java and extent it with Application and add put this code in the OnCreate sections
public class Firebasedata extends Application {
@Override
public void onCreate() {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
super.onCreate();
}
}
declare the java class in the manifests
Then go back to the class where you want to get the data and create a dialog with this code
ProgressDialog TempDialog;
CountDownTimer mCountDownTimer;
int i=0;
TempDialog = new ProgressDialog(MainActivity.this);
TempDialog.setMessage("Please wait...");
TempDialog.setCancelable(false);
TempDialog.setProgress(i);
TempDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
TempDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.GRAY));
TempDialog.show();
mCountDownTimer = new CountDownTimer(2000, 1000)
{
public void onTick(long millisUntilFinished)
{
TempDialog.setMessage("Please wait..");
}
public void onFinish()
{
TempDialog.dismiss();
//Your action like intents are placed here
}
}.start();
You can look into the link above and get a better idea