Whats the best approach for my project? [closed] - android

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.

Related

How to get Internet Speed? [closed]

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

which one is best AlarmManager or Handler post delay for repeating background task [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have to repeat a weather API Task after every half an hour to fetch data from the http://api.openweathermap.org for that I have used handler post delay but some one suggests me to use Alarm manager for repeating task as It produces interrupt. but if we use handler it consume more memory and uses more Cpu. I need suggestion which one is best.
The docs for AlarmManager point it out when to use it.
Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.
In your case your app will not be visible all the time since it's a weather app. It makes sense to use AlarmManager here to update the data. For more pro's and con's there are more answers here
It's always case dependent.
Previously SyncAdapters were used for performing long performing operations, Now JobSchedular is the latest background monitoring service which can be used.

Firebase listener effect on battery life and CPU [closed]

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.

how to get location at regular intervals using android api? [closed]

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

Detecting that a user has entered a physical location with her Android / iOS device [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
If a user has a particular app installed on her phone but the app is not running in the foreground, what is the best way to detect that she has entered a physical location with the Android / iOS device? Assume that the app has all the required permissions and in the case of Android, there is a background service running every minute.
I can think of polling the GPS but the drawback is that the user might have switched off her GPS.
The same would happen with a possible bluetooth wake-up if bluetooth is off. Ditto for WiFi.
Could something like supersonic sound emitted from a hardware placed at the entrance of the location work? (Something like Tagtile perhaps?)
Which of these 4 would you most rely on? for Android? for iOS? Or would you rather use some other method?
It is possible to track a users whereabouts. While I will not go on to explain how the entire process is done (as it would be the equivalent of writing my own tutorial on the subject), it is gone over in detail in the Apple Docs, covered here(I believe what you are looking for is the CLLocation).
This can even run in the background, as also covered in the Apple Docs in many place, one of them being here.
For an iOS app, that is what I would recommend.
If the user turns off Location Tracking and/or their GPS, I believe you are going to have to deal with it. Tracking a person, when they have not given permission or explicitly denied the permission to do so, is illegal in many countries.
EDIT
Escaping my mind for a moment was the Google Location API. Probably one of the most known and used Location services will get you your tracking for Android.
EDIT 2
If a person has turned off their GPS or Wifi, there would not be a way to tell their physical location. If you were able to track a person when their Wifi or GPS was turned off would classify your app as spyware, and would not be a good idea.

Categories

Resources