firebase-realtime-database

Firebase multiple queries in android

馋奶兔 提交于 2020-04-18 05:45:44
问题 I have this database: The candidates collection contains several categories such as president and secretary. It also has totalVotes for each candidate. I would like to query: Results by category eg President or Secretary The candidate with highest 'totalVotes' per category, i.e, the President with the highest votes, and the secretary with highest votes. Here is my code that is not working: DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); DatabaseReference

Hide a Checkbox for the current user that is logged in the App

送分小仙女□ 提交于 2020-04-18 04:59:40
问题 I am trying to hide a CheckBox for the user that is logged in. I display my data from firebase in a RecyclerView with populateViewholder . And I want to hide the CheckBox from the current user logged in. But I am struggling to get it right. MainActivity: public class WishItemsActivity extends AppCompatActivity { private FirebaseAuth mAuth; private DatabaseReference UsersRef, WishListRef, WishItemsRef; static String currentUserID; private ImageButton ibaddnewwishlistitem; private String Key,

How to use Firebase Realtime Database stream using Pyrebase?

天涯浪子 提交于 2020-04-17 20:37:09
问题 I have installed pyrebase in an online python server which is pythonanywhere and I'm trying to use the stream to check the changed values at child node when I get a request from HTTP client. Here's the code: from flask import Flask from flask import request import requests import pyrebase firebase = pyrebase.initialize_app(config) app = Flask(__name__) @app.route("/IOTSENSE/PINS", methods=["POST","GET"]) def handler(): username = request.get_data() print(username.decode("utf-8")) username =

How to await two requests with Promise.all then invoke other functions in callback?

徘徊边缘 提交于 2020-04-17 19:31:33
问题 I'm trying to wait for two requests I get data from firebase DB and set into a state, I want after two requests Done, concatenate result data in one array, So I tried to push two requests in an array then use > Promise.all(promises).then(()=>this.updateData()); but it does not work as expected, I can see in the console updateData() invoked before " Code here fetchOrders = async () => { .... let promises = []; promises.push( // First service orders database() .ref( `Providers/CategoriesOrders/

How to await two requests with Promise.all then invoke other functions in callback?

为君一笑 提交于 2020-04-17 19:31:27
问题 I'm trying to wait for two requests I get data from firebase DB and set into a state, I want after two requests Done, concatenate result data in one array, So I tried to push two requests in an array then use > Promise.all(promises).then(()=>this.updateData()); but it does not work as expected, I can see in the console updateData() invoked before " Code here fetchOrders = async () => { .... let promises = []; promises.push( // First service orders database() .ref( `Providers/CategoriesOrders/

How to await two requests with Promise.all then invoke other functions in callback?

强颜欢笑 提交于 2020-04-17 19:30:46
问题 I'm trying to wait for two requests I get data from firebase DB and set into a state, I want after two requests Done, concatenate result data in one array, So I tried to push two requests in an array then use > Promise.all(promises).then(()=>this.updateData()); but it does not work as expected, I can see in the console updateData() invoked before " Code here fetchOrders = async () => { .... let promises = []; promises.push( // First service orders database() .ref( `Providers/CategoriesOrders/

How to get value from POJO and set value to TextView

坚强是说给别人听的谎言 提交于 2020-04-16 02:55:46
问题 How can I get value from POJO and set its value to TextView in android studio MainActivity.java onCreate method: FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser(); assert user != null; String UserID=user.getUid(); UserInfoPOJO userinfopojo = new UserInfoPOJO(UserID); UserInfoPOJO.java public class UserInfoPOJO { private String UserID; public UserInfoPOJO(String userID) { UserID = userID; } public String getUserID() { return UserID; } public void setUserID(String userID) { UserID =

Firebase rule to only allow one update in android studio

只愿长相守 提交于 2020-04-16 02:13:32
问题 I'm creating an android studio voting application. It is using recyclerview to render candidates information from the database. Once the voter clicks on a vote button, the candidate is added a vote on the firebase realtime database. I wanted to make sure that a voter can only vote once. Is there a firebase rule I can use or do I have to do it in code? public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { holder.name.setText(candidates.get(position)

Kotlin and Firebase read and write data

我与影子孤独终老i 提交于 2020-04-14 09:54:42
问题 I have learned Kotlin for 3 weeks so I would like to read the data from my Firebase database. This is the MainActivity.kt to write the data. val database = Firebase.database val latitude = latitude.text.toString().toDouble() val reflatitude = database.getReference("/user/time/$currenttime/latitude") //saved location to the Firebase Database reflatitude.setValue(latitude) .addOnSuccessListener { Log.d("MainActivity", "Saved the diary latitude to Firebase Database") } It worked well, but when I

Firebase Event Listener inside Android Worker

末鹿安然 提交于 2020-04-11 07:09:05
问题 I am trying to implement a Worker from Android WorkManager with an Event listener for Firebase database reference. It works fine if the app is in foreground/background. But once I close the app and the worker runs the event listener is not triggering, As far as I can tell I am not getting any error messages related to this in log. Here is a sample code: class FirebaseWorker(context: Context, params: WorkerParameters) : Worker(context, params) { override fun doWork(): Result { val