Detecting a phone in the map

I'm far to be an expert on Android programming, so I don't have any idea about if this is possible, so let me split my doubt in three questions:

1) Is it possible for an Android app to detect all the other Android devices in a map that have the same app installed, within a radius previously given (for example, say 5 km)?

2) If yes, is it also possible to show their phone numbers (with their consent, of course)?

3) How much time, approximately, would an experienced Android programmer need to do that?

Upvotes: 1

Views: 176

Answers (1)

ngrashia
ngrashia

Reputation: 9904

To answer your question

  1. YES! Possible provided

    • All the users within the prescribed radius should have GPS enabled and you should be having the lat/long of all users current coordinates(Or atleast last known coordinates should be saved periodically) saved in DB.

    • To calculate the 5 km radius, you can use oracle query and function that gives you the list of closest people. Below function gives you the distance between 2 geo-coordinates in KM. create or replace FUNCTION CALC_DISTANCE (Lat1 IN NUMBER, Lon1 IN NUMBER, Lat2 IN NUMBER, Lon2 IN NUMBER) RETURN NUMBER IS -- Convert degrees to radians DEGTORAD NUMBER := 57.29577951; Radius NUMBER := 6387.7; BEGIN RETURN(NVL(Radius,0) * ACOS((sin(NVL(Lat1,0) / DegToRad) * SIN(NVL(Lat2,0) / DegToRad)) + (COS(NVL(Lat1,0) / DegToRad) * COS(NVL(Lat2,0) / DegToRad) * Cos(Nvl(Lon2,0) / Degtorad - Nvl(Lon1,0)/ Degtorad)))); END;

    • By using a select query like, SELECT * FROM USER_LIST WHERE CALC_DISTANCE(MY_LAT,MY_LONG, USER_LAT, USER_LONG) <=5 ; you can fine the list of closest users and display to the user requesting information.

    • This can drain battery and so, it is advisable to not have listing the friends dynamically. Instead the user can have something like 'Find Users' and then your app can list the nearest users.

  2. Getting phone numbers via android app depends on the cellphone carrier and provider. So, we cannot guarantee to obtain cell phone numbers automatically and provide to other user. However, in case you get all the user's cell phone number manually when they first login, this can be possible. The code snippet is however available here Programmatically obtain the phone number of the Android phone. But mind you, in most of Indian numbers, we have observed, this does not work.

  3. That depends on other factors and I am not the right person to comment!

Upvotes: 1

Related Questions