Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do I set Android app to retrieve location of a device once a minute?
Do I need to use MongoDB and Node.JS stack instead of MySQL due to high load nature of a service? I.e. there will be high amount of simultaneous location requests from clients to a single server.
MongoDB (NoSQL) is not a panacea for scaling. Your description of a problem looks like it could use the advantages of structured storage, thus SQL might be a good choice afterall.
And I must use Node.js and socket.io with android
Up to you, but there is no must in using this technology stack.
// Set the update interval to 1 minute
mLocationRequest.setInterval(60000);
See the documentation here.
Use the LocationRequest.setInterval to receive an location update each minute.
Update interval
Set by LocationRequest.setInterval(). This method sets the rate in milliseconds at which your app prefers to receive location updates. If no other apps are receiving updates from Location Services, your app will receive updates at this rate.
You can find a downloadable example at http://developer.android.com/training/location/receive-location-updates.html
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Currently, I am struggling to show the internet speed consistently in the status bar. What I am able to do is, finding the internet speed by the old approach(Upload & download some file from/to server and using TrafficStats API). I tried some of the play store apps, they all displaying the internet speed when the user opens up any app which uses the internet. I want to implement the same feature. I believe they either use a broadcast receiver or service. How can I implement the same?
Or is there any library which does the same or any other better approach?
The problem with displaying an internet speed is that it is always going to be 'historical' or an estimate - i.e. even if you were able to achieve 300Mbps 1 second ago it does not mean you will be able to achieve it now.
Bearing this in mind, the approach you already outlined is as reliable as any - i.e. measure the round trip time for a known size of data. If accuracy is important to you, this is probably the most accurate provided you are confident of the turnaround time on the server side.
You can listen to Android Network events which will tell you when the type of network connections has changed etc - the recommended approach has changed over API levels but this is a good starting point: https://developer.android.com/training/monitoring-device-state/connectivity-monitoring
For your example it sounds like you want to get as recent as possible Network Stats rather than connectivity changes - for that the 'NetworkStatsManager' is probably the best match.
Provides access to network usage history and statistics. Usage data is collected in discrete bins of time called 'Buckets'.
https://developer.android.com/reference/android/app/usage/NetworkStatsManager
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
If I were to write a mobile app that recorded the GPS location of the device, how certain can I be that the GPS location hasn't been tampered?
To avoid confusion, I'm not concerned with the resolution/accuracy of the GPS, I'm more concerned with security. Can the GPS coordinates be hacked so that my app records an incorrect location?
Can I demonstrate that the GPS coordinates recorded by the app can be relied upon?
Yes, it can be hacked. On Android there's a debugging system that allows fake locations. Or they could always use a custom build of Android that just lies. Never trust ANY data from a client you don't control to be accurate. Even if they couldn't fake the GPS data, they could alter your app and make it upload bad data.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
If I want to have a service in my android app that listens from Firebase if a child has been added to the signed user friend's request, does it affect the battery or the CPU of the users? I yes, should I consider finding another solution? I plan to have 3 other listeners in the background as well. Thanks.
This is a pattern you should avoid because:
1) The device may disconnect the network from your Android app in doze mode in newer versions of Android. If you're trying to get notified at any time of any change, this is not going to work.
2) Firebase Cloud Messaging is a better way to reliably wake a device to handle a change that your app needs to know about.
Firebase Realtime Database uses a websocket to let a client know when things change. At least the drain on battery from an open socket is not a big deal. You just shouldn't count on that connection unless your app is visible and has a reliable network connection.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Am developing a tracking app for android where user will be tracked for 8hrs minimum a day.
data will be retrieved from GPS and once data retrieved it will be sent to server.
What I have done till now is
data will be retrieved every 30 seconds if he is on bike (speed >= 13mph) if less than that then every 1sec.
created a activity and using requestlocationupdates() retrieving data and sending to server using asynchronous tasks.
I saw many ppl recommending service for long run tasks and alarm manager instead of using minTime and minMeters of requestlocationupdates().
So am confused.
What would be best approach for this? am mainly developing it for low end devices so battery is my main constraint.
And tracking should not get stopped.
If battery is your concern, you don't want to use GPS. GPS kills the battery. You want to use network location instead. Its less accurate, but much nicer on the battery.
I did something similar for driving, I used a service and an alarm rather than the minimum time and distance, just because using fixed time intervals made my math easier.
If using Google Play Services is an option, APIs like the DetectedActivity might be useful for you. From what I've read, they spent some time working on making the API smart about things like battery life and location services.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to create an application that will show me on a map to all users who have installed my app within x distance.
It wondered if I need to save the coordinates of each user periodically in a database and read the position or is there another option
Tracking the user's location in a database will likely be your easiest option. It will also scale well. If you are only tracking a couple users, you could use another simpler data storage mechanism like an XML file, a text file, or even some sort of Application Level Variable.
I'm sure that you have done some research on how best to track your users, but this is a pretty good starting point, if you don't have one already. They are storing each location in a local database on the phone, so I'm sure that you could very easily modify it to send that same location to a web service or something.