Android: Detect if user is on a bus/train/tram/etc - android

I know this is a very open question, but does anyone know how I can determine if a user is on public transport? Ideally, I'd have a background service running such that only subscribers who are on public transport receive my alerts.

how I can determine if a user is on public transport?
You ask the user, "Yo! You on public transport?"
Perhaps a fusion of maps data and sensors?
You can use the activity recognition portion of the Google Play Services location API to determine if the user is in a moving vehicle.
However, there is no requirement for governments to collect, let alone publish, the GPS coordinates of all public transportation vehicles. Hence, there is no way for you to determine the location of all the world's buses, trains, trams, etc. And, as a result, you have no way to determine if the user is on one of those.

Every method of transportation has it's own move-characreristics. E.g. a train takes long time to speed up and down. A bus takes little shorter and stops more often. Analyzing these accelaration-characferistics should give a hint on the form of transportation.
Next, you could analyze the routes using map Information, if you can get it somewhere. May be you van gather it yourself: record a route, let user tell whether he/she is on train, bus, walking. Save this Information for later use, also for other travellers.
Lot's of possibilities. All are rather difficult.

Related

DJI SDK: Pause/Resume Waypoint mission when arriving on point?

I haven't found any info on this. I'd like to build a waypoint mission like this:
drone arrives at waypoint
whole mission pauses, notifies the user (is there a listener for waypoints?)
app goes to another activity to take photo
user comes back from photo activity
user presses button, mission continues to next waypoint.
I see the waypoint actions but it's not exactly what I'd like to achieve. I'd like to let the user control the mission manually, but have the option to do things like skip waypoints, but also to go to another activity while the drone is waiting at a waypoint.
Any tips on this?
Thanks
This answer pertains specifically to the android SDK, but similar concepts exist for the iOS SDK as well.
In Android, waypoint missions are created and controlled through the WaypointMissionOperator class. Instances of this class allow for setting a listener through the addListener method that will be called when updated aircraft state is available. The onExecutionUpdate method of the WaypointMissionOperatorListener that you pass to that method will receive a WaypointMissionExecutionEvent. This object has a getProgress method which will give you information on the state of the mission that you need (
targetWaypointIndex and isWaypointReached).
To pause the mission at a specific waypoint, you may want to add a hold at the waypoint. This allows your software running on the mobile device time to detect that the aircraft has reached the waypoint and send a mission pause command.
The rest of your question gets into a bit of design philosophy which is a bit out of scope for stackoverflow, but feel free to contact me directly.

Fetch accurate intermediate Location points in background and calculate Distance of Starting and ending locations in Android

There may be similar questions regarding this topic,But I need your thoughts and suggestions on some specific requirement.
Here is my need -
We are developing one app which tracks User's trip.
The app will start collecting the location of that user in background,When user 'Starts' his trip from App.Background Service will be fetching locations on the basis of user's movement in specific time duration.
When User 'Stops' his trip from App,We are calculating distance traveled by user with help of all recorded locations(With Google Distance calculating API).
The App works fine in ideal case.
But main challenge is -
In some scenarios,We are not able to fetch exact and precise location of User. Scenarios affecting is - No internet,Data plan with 2g/3g,some specific areas where GPS is not returning accurate data etc.
Incorrect data of lat-long causes incorrect Trip distance and route.Which is main problem with the App.
Please,any one can suggest the best alternative/Suggestion for this?
P.S. - We have tried GPS,Network,FusedLocationProvider.
EDIT 2 --
We have implemented logic on basis of accuracy and distances.Got nearer points. And just came across one useful api from Google that corrects some location points which are distracted from actual Roads. Posting here for reference of others...
Snap to Roads Api from Google
this is a complicated topic.
One consideration you have to take. Android Oreo limits background services and that what you want to achieve won't work.
I would do is this (and it is the recommendation from Google)
When someone starts the trip (the user is aware of it), you must launch a on going notification with a foreground service , don't rely on background services anymore. Check the feature "Start Activity" in Google Fit App.
As for not having signal, or accurate GPS, well... it is a geographical problem!, there is nothing you could do. Or, maybe you can, using the LocationProvider.
FusedLocationProvider is fused within every app that requests locations updates.
Read this out, and see if that helps you.
https://developer.android.com/guide/topics/location/strategies.html
Try to mix GPS and Accelerometer
If you detect that GPS stopped working, turn on accelerometer. If GPS is turned on again, calculate distance again with it. This way you can have route with GPS parts and accelerometer ones. The bigger GPS parts, the more accurate data will be
How to get more accuracy by GPS_PROVIDER
Basically if the accuracy of a location isn't acceptable throw it away. The next one will be better.

Use the bus stop announcment system to detect whether the user is in the bus or not

I am implementing an app to track the location of buses based on Crowdsorcing. The riders send data long, lat, mac, route, timestamp to the server as JSON string which is being inserted into the bus table. The waiting rider at the stop can query the server to get the location of their diserable route.
The route in the JSON string is not always known so I cant always use it to detect whether the rider is in the bus or not. Therefore, I am trying to use the bus stop announcment system to determine that. In the bus there is a announcer which notifies the name of the next stop. Is it possiable to recognize this sound with the microphone of the Android device to say the user is in the bus?
I appreciate any help.
Firstly about the idea: "app to track the location of buses based on Crowd sourcing": You should definitely need an active User community to update the details.
And Second thing: "JSON string is not always known" You addressed the issue here and changed your mind to make use of announcer information. The question is: How to capture the announcer information? I totally understand that people started playing with Siri, Cortana, etc.
Here are few suggestions from my tracking experience:
1. If you wanna track a bus, the bus should have some kind of inbuilt tracking device which sends Lat,Long information to the server.
2. You must have server side to process these messages.
3. Your app can communicate with the server to get real time information.
4. There are many bus tracking app's already available in market, you can do a quick search in Play Store.
Definitely, I would not discourage the idea of tracking the real time location of bus; I have personally used different apps to track buses and found useful. But there is no concept of Globalization that you can use a single app to track different Buses running in different states/countries.

Can I detect when a user moves through an intersection?

I am in the process of planning an app that includes a feature that requires it to record and store the exact route a user takes while driving. Is there any location api that supports this out of the box? Or supports detecting a turn? I was initially hoping for an event triggered by the user turning onto a different road, but so far, no such luck.
I think you may try this way:
1 Request for GPS location update every 30s ,you can do this with Timer and TimerTask ,and LocationManager;
2 You can get the road name through Google Map API with the GPS location you get;
3 So you will get to know whether the user is turning onto a different road every 30 seconds.
I believe I have found a solution that makes use of the other answer here. I will post it as a separate answer though as it adds more to the other answer and is a full solution. As Ai Hao said, I could have my app request an updated location every 30 seconds to determine whether the user is on a new road, and then place a waypoint signalling the turn. However, this method is flawed if the mapping algorithm used (and I do not have the expertise to write my own) detects multiple possible routes. My solution to this issue is to store all location responses until a turn is made. This means that when a turn is detected, the oldest location data will be the last turn, while the newest will correspond to the turn being made. The app will request alternate routes, and if any are found, will calculate a route between the second oldest and second most recent coordinates, until no alternate routes are found. This should result in the exact route that the user took.

GeoFence or distance calculation... what's the difference?

I read in the documentation that I can setup geofencing so I know when the user entered/left the geofenced area.
However, I was wondering, can't I get the same behaviour by just taking my current location (ona regular location update) and check the distance with the center of the intended geofence. If it is less than a certain radius then I am within that area.
Wouldn't that have the same effect (infact way less code than geofence)?
Thank you
I believe the advantage of a geofence as opposed to what you describe, is that geofences are objects that come with a lot of extra support in Google Play Services. Using geofences allows multiple different Activities or even Applications to get notifications/callbacks from a single (or set of) geofence objects created elsewhere. These callbacks will happen automatically even if you are in another application because Google Play Services can monitor location in the background without you writing additional code in your Activity, and they can expire on their own. Doing this would be more difficult if you were to roll your own distance calculations as you would have to set it up your own Service framework.
From this answer by CommonsWare:
Geofences are designed to work even without your application running.
However, if your goal is only to check whether you are a certain distance from a geographical point (without caring about what happens when the user goes to check their email or puts their phone back in their pocket), then what you describe might be easier.

Categories

Resources