Android geofire get a list of users within certain radiusStatic way to get 'Context' in Android?How to get the build/version number of your Android application?Get current time and date on Androidgps not getting user locationStoring values with GeoFire node on AndroidRemove and re-insert a GeoFire location to trigger onKeyExited and onKeyEntered doesn't workGeoFire data has invalid format exceptionGet children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidUsing GeoFire to store user latitude and longitude into my database - It's not updating consistently
How could Frankenstein get the parts for his _second_ creature?
Was Spock the First Vulcan in Starfleet?
What's the purpose of "true" in bash "if sudo true; then"
What is the intuitive meaning of having a linear relationship between the logs of two variables?
How do I keep an essay about "feeling flat" from feeling flat?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Can I Retrieve Email Addresses from BCC?
Is HostGator storing my password in plaintext?
How was Earth single-handedly capable of creating 3 of the 4 gods of chaos?
Can a monster with multiattack use this ability if they are missing a limb?
Is it correct to write "is not focus on"?
Finding all intervals that match predicate in vector
Your magic is very sketchy
How do I rename a LINUX host without needing to reboot for the rename to take effect?
Personal Teleportation as a Weapon
Can criminal fraud exist without damages?
Is there a good way to store credentials outside of a password manager?
Was the picture area of a CRT a parallelogram (instead of a true rectangle)?
Can somebody explain Brexit in a few child-proof sentences?
Greatest common substring
Generic lambda vs generic function give different behaviour
Why does John Bercow say “unlock” after reading out the results of a vote?
Bash method for viewing beginning and end of file
Android geofire get a list of users within certain radius
Static way to get 'Context' in Android?How to get the build/version number of your Android application?Get current time and date on Androidgps not getting user locationStoring values with GeoFire node on AndroidRemove and re-insert a GeoFire location to trigger onKeyExited and onKeyEntered doesn't workGeoFire data has invalid format exceptionGet children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidUsing GeoFire to store user latitude and longitude into my database - It's not updating consistently
I am trying to add all users to a List which are within a certain distance from a users location. I have successfully gotten a users current location and I store this in my database using geofire. I know I have to use geofire to query the results but I am unsure on how to add the users to my list. I believe that this is done within the onKeyEntered method but I am unsure.
private void addLocationToDB()
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
geoFire = new GeoFire(database);
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
private void getListNearbyUsers()
geoQuery = geoFire.queryAtLocation(new GeoLocation(latitude, longitude), 1);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
nearbyUsers.add(key);
@Override
public void onKeyExited(String key)
@Override
public void onKeyMoved(String key, GeoLocation location)
@Override
public void onGeoQueryReady()
@Override
public void onGeoQueryError(DatabaseError error)
);
android firebase firebase-realtime-database geofire
add a comment |
I am trying to add all users to a List which are within a certain distance from a users location. I have successfully gotten a users current location and I store this in my database using geofire. I know I have to use geofire to query the results but I am unsure on how to add the users to my list. I believe that this is done within the onKeyEntered method but I am unsure.
private void addLocationToDB()
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
geoFire = new GeoFire(database);
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
private void getListNearbyUsers()
geoQuery = geoFire.queryAtLocation(new GeoLocation(latitude, longitude), 1);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
nearbyUsers.add(key);
@Override
public void onKeyExited(String key)
@Override
public void onKeyMoved(String key, GeoLocation location)
@Override
public void onGeoQueryReady()
@Override
public void onGeoQueryError(DatabaseError error)
);
android firebase firebase-realtime-database geofire
add a comment |
I am trying to add all users to a List which are within a certain distance from a users location. I have successfully gotten a users current location and I store this in my database using geofire. I know I have to use geofire to query the results but I am unsure on how to add the users to my list. I believe that this is done within the onKeyEntered method but I am unsure.
private void addLocationToDB()
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
geoFire = new GeoFire(database);
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
private void getListNearbyUsers()
geoQuery = geoFire.queryAtLocation(new GeoLocation(latitude, longitude), 1);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
nearbyUsers.add(key);
@Override
public void onKeyExited(String key)
@Override
public void onKeyMoved(String key, GeoLocation location)
@Override
public void onGeoQueryReady()
@Override
public void onGeoQueryError(DatabaseError error)
);
android firebase firebase-realtime-database geofire
I am trying to add all users to a List which are within a certain distance from a users location. I have successfully gotten a users current location and I store this in my database using geofire. I know I have to use geofire to query the results but I am unsure on how to add the users to my list. I believe that this is done within the onKeyEntered method but I am unsure.
private void addLocationToDB()
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
geoFire = new GeoFire(database);
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
private void getListNearbyUsers()
geoQuery = geoFire.queryAtLocation(new GeoLocation(latitude, longitude), 1);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
nearbyUsers.add(key);
@Override
public void onKeyExited(String key)
@Override
public void onKeyMoved(String key, GeoLocation location)
@Override
public void onGeoQueryReady()
@Override
public void onGeoQueryError(DatabaseError error)
);
android firebase firebase-realtime-database geofire
android firebase firebase-realtime-database geofire
asked Mar 7 at 11:43
user10431501user10431501
448
448
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Anyone looking for the answer I figured out my mistake. This method should take the userID as a argument not "Location". I can then get all "keys" as userID and filter the data. Hope this helps anyone with the same problem.
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
add a comment |
I hope this might Help,gets users in a radius of 10km/10000m
Location mLastLocation;
boolean getUsersAroundStarted = false;
private void getDriversAround()
getUsersAroundStarted=true;
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
GeoFire geoFire = new GeoFire(database);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()), 10000);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
//add users to Firebase Database
);
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042969%2fandroid-geofire-get-a-list-of-users-within-certain-radius%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Anyone looking for the answer I figured out my mistake. This method should take the userID as a argument not "Location". I can then get all "keys" as userID and filter the data. Hope this helps anyone with the same problem.
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
add a comment |
Anyone looking for the answer I figured out my mistake. This method should take the userID as a argument not "Location". I can then get all "keys" as userID and filter the data. Hope this helps anyone with the same problem.
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
add a comment |
Anyone looking for the answer I figured out my mistake. This method should take the userID as a argument not "Location". I can then get all "keys" as userID and filter the data. Hope this helps anyone with the same problem.
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
Anyone looking for the answer I figured out my mistake. This method should take the userID as a argument not "Location". I can then get all "keys" as userID and filter the data. Hope this helps anyone with the same problem.
geoFire.setLocation("Location", new GeoLocation(latitude, longitude), new GeoFire.CompletionListener()
@Override
public void onComplete(String key, DatabaseError error)
if(error != null)
Log.d(TAG, "Problem storing users location - onComplete: " + error.getMessage());
else
getListNearbyUsers();
);
answered Mar 7 at 12:47
user10431501user10431501
448
448
add a comment |
add a comment |
I hope this might Help,gets users in a radius of 10km/10000m
Location mLastLocation;
boolean getUsersAroundStarted = false;
private void getDriversAround()
getUsersAroundStarted=true;
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
GeoFire geoFire = new GeoFire(database);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()), 10000);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
//add users to Firebase Database
);
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
add a comment |
I hope this might Help,gets users in a radius of 10km/10000m
Location mLastLocation;
boolean getUsersAroundStarted = false;
private void getDriversAround()
getUsersAroundStarted=true;
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
GeoFire geoFire = new GeoFire(database);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()), 10000);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
//add users to Firebase Database
);
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
add a comment |
I hope this might Help,gets users in a radius of 10km/10000m
Location mLastLocation;
boolean getUsersAroundStarted = false;
private void getDriversAround()
getUsersAroundStarted=true;
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
GeoFire geoFire = new GeoFire(database);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()), 10000);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
//add users to Firebase Database
);
I hope this might Help,gets users in a radius of 10km/10000m
Location mLastLocation;
boolean getUsersAroundStarted = false;
private void getDriversAround()
getUsersAroundStarted=true;
database = FirebaseDatabase.getInstance().getReference("Leaderboard").child(userID);
GeoFire geoFire = new GeoFire(database);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(),mLastLocation.getLongitude()), 10000);
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener()
@Override
public void onKeyEntered(String key, GeoLocation location)
//add users to Firebase Database
);
edited Mar 7 at 12:15
answered Mar 7 at 12:08
MitchellYuenMitchellYuen
2310
2310
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
add a comment |
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
Hi, The code within the onKeyEntered method is what I am confused on. How do i get the list of users to add to the Database?
– user10431501
Mar 7 at 12:10
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
are you asking to get a list of user in a particular radius and then add them to a firebase database?
– MitchellYuen
Mar 7 at 12:12
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
Yes, thats what I am trying to achieve
– user10431501
Mar 7 at 12:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042969%2fandroid-geofire-get-a-list-of-users-within-certain-radius%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown