Prove that 2 mobile devices are close to each other - android

Let's say I'm developing an app (Android, iOS or both), and 2 users (UserX & UserY) have downloaded my app with giving it all permissions needed,
If UserX opened the app telling it "hey app, I'm currently close to UserY's mobile" (like in the same room or something), where UserY's mobile could be just laying down doing nothing,
Question is, can the app make sure UserX's claims are valid or not? .. if yes, then is it valid for both platforms (Android & iOS)?

You can create Geofence for both user x and user y and based on the radius of geofence you can generate an alert if users cross into each others geofences.
Geofencing combines awareness of the user's current location with awareness of the user's proximity to locations that may be of interest. To mark a location of interest, you specify its latitude and longitude. To adjust the proximity for the location, you add a radius. The latitude, longitude, and radius define a geofence, creating a circular area, or fence, around the location of interest.
You can have multiple active geofences, with a limit of 100 per app, per device user. For each geofence, you can ask Location Services to send you entrance and exit events.
Here are more info on the same - https://developer.android.com/training/location/geofencing

Related

Android: Does geofence automatically update the user position?

From what I know, the Google API Geofence should automatically retrieve the location of the device based on some parameters (e.g. the distance from the area). However, I've been trying to implement the code provided here and run it on the virtual machine for several minutes, but the current location of the device is never updated.
So, it is not clear to me if the Geofence automatically and periodically retrieves the location of the device, or simply uses the last known location.

Android geofences - doubts about the concept and limits

I am trying to understand the geofences concept correctly, in my case for an android app, and I have two questions.
Based on the documentation and examples, I see that I can create a zone based on a longitude, a latitude, and a radius, and I can create alerts when entering or exiting that zone.
so far, everything is correct.
My intention is the following:
I want to create a zone and be notified if another user, also with my app installed, enters the zone I have created.
Is this possible with geofences?
I am reading about it, but it is not clear to me if it is possible.
My second question is: the limit of 100 geofences per app, is it for each application package name, or for each installed application?
"Is this possible with geofences?" yes, just for every user fetch geofences data for somewhere (filessystem, enter by hand, form backend) and set up geofences on this particular piece of android device

Android Geofencing: Trigger only while outside geofence

I am making a geofencing application, which must trigger notification constantly while the device is outside the geofence, not only on exit.
I have tried using Geofencing API through the training example given in Google android developer training page. But, I got notification only when the device enters, dwell or exit.
According to what I have researched till now in both SO and google, there are only three types of transitions handled in Geofencing API: Enter, Dwell and Exit. And the notification starts only when device enters the geofence, till it exits.
Can anyone help me out how to make it work?
That is not possible that way. It does not make any sense outside the geofence area. That is not an usecase of geofence.
You can try to specify broader range of the area and then check the geocoordinates if this is outside of your area you want to have.
Incase you want your own custom exit trigger, when you are outside the fence. You can write your custom action by measuring distance(lat,long) between your current location(FusedLocationProvider) and the fence location (lat, long).
You can use below methods available in Android Location API to measure the difference and generate a custom trigger to indicate that you are outside the fence.
Typically this is what you need to do
if[ (difference in location) > (Radius of your geo fence) ] -> Custom Exit of Fence Action
distanceTo
distanceBetween (Provide both your current lat,long and your fence lat,long here)

Android Tracking App - check if someone is getting closer or distancing from specific point

I created an android app, which stores user's home location and count distance between home and his/her actual location, in a Service class.
Now I would like to programme feature that would decide based on counted distance, if a user is:
at home
away
getting closer
distancing from home
This should be similar to Google Now, that can predict that you are for example going home. If someone had some examples, I would be sooo grateful
To implement such kinda work, you need to implement GeoFence in your android app.
GeoFence gives you idea about user entered/exited from a defined area. If you set home location as base location and radius to 500m then it gives you entered callback you are within 500m of your home.
When you go away 500m from your home location then it gives you exited callback. To know about whether you are home location then at a interval of few minutes you can poll GPS coordinates then can identify whether you are at your home location.
https://developer.android.com/reference/com/google/android/gms/location/Geofence.html

I want to popup if user come in gps range using android development?

I have a question related to the gps system in android.
I want to have the following functionality in my android app:
-Once the application is installed on the android device then it is always running in the background.
-I have a gps enabled android device then if I am 300-400 meters away from a particular address(Where address means we have provided the address to the application for finding location) then a popup appears on the screen stating I am x meters away from the target. (I would want this popup to occur every time I am 100m closer)
I have tried looking on Google for the correct way to do this but I have been unsuccessful and any help would be appreciated.
My main problems are:
1)Always having my program running in the background.
2)Have a popup to notify the user.
3)How to calculate my distance from a particular location.
You can get the distance in meter by
Location location;
float distance[];
location.distanceBetween(From Latitude, From Longitude, TO Latitude, TO Longitude,
distance);
When you user goes 300 meter , you can popup the screen in home activity (Use background service to do that)
Once app installed stat the service. Remember that user can kill the service

Categories

Resources