GithubHelp home page GithubHelp logo

Comments (11)

bfabiszewski avatar bfabiszewski commented on July 17, 2024 2

It sounds fine.
Thanks @mendhak for helpful insight!

Personally I don't need such feature, but I think I could add it as an optional thing, allowing user to select additional extra data that is logged.
This will however have to wait, because I am terribly busy now, sorry :(

from ulogger-android.

julien-nc avatar julien-nc commented on July 17, 2024 2

Thanks for considering this !

from ulogger-android.

julien-nc avatar julien-nc commented on July 17, 2024 1

Do you really think getting the phone's battery status each time the app logs a position is battery consuming ? I would say that it just reads the information provided by Android API which must not cost a lot.

I would love to have that information sent with each position !

BTW : thanks for this great app.

from ulogger-android.

bfabiszewski avatar bfabiszewski commented on July 17, 2024

If we wanted to have updated battery status every time we log position it would mean using more resources. We would have to use more battery in order to get battery status ;)
On the other hand we could just subscribe to low battery broadcasts. Then we could only log two states: battery low and battery ok. Would it be useful? I'am not convinced.

from ulogger-android.

rui00rodrigues avatar rui00rodrigues commented on July 17, 2024

In fact battery status is usable in case we are getting positions periodically. It will be good feature to allow tracking periodically without the need of GPS sensor to be always on. What you think?

from ulogger-android.

bfabiszewski avatar bfabiszewski commented on July 17, 2024

This is how I understand it. Read here:

Generally speaking, the impact of constantly monitoring the battery level has a greater impact on the battery than your app's normal behavior, so it's good practice to only monitor significant changes in battery level—specifically when the device enters or exits a low battery state.

And monitoring significant changes means monitoring two states: ACTION_BATTERY_LOW and ACTION_BATTERY_OKAY.

from ulogger-android.

julien-nc avatar julien-nc commented on July 17, 2024

I thought the battery status was stored somewhere by the system and that accessing it had a very low cost... Just like accessing the device name 😉. I mean, it should not be costly.

GpsLogger, which is very battery-saving-oriented, gets the battery level for each logged point. I'll ask the dev what he thinks about that topic.

from ulogger-android.

mendhak avatar mendhak commented on July 17, 2024

It's a sticky broadcast, so yep it does become expensive if it's being queried frequently. The way I've done it is here - no application level receivers, just that method and which by default gets called once a minute. From testing that's had no adverse effect on battery life.

So if you were to do this, it's worth setting some kind of a minimum time between these requests.

public static int getBatteryLevel(Context context) {
    Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    int level = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) : 0;
    int scale = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1) : 0;

    if (level == -1 || scale == -1) {
        return 50;
    }

    return (int) (((float) level / (float) scale) * 100.0f);
}

from ulogger-android.

julien-nc avatar julien-nc commented on July 17, 2024

To make it short : the battery level could be stored by the app and updated every minute (or even 10 minutes). This stored value would be sent with each logged point. This way, there are not too many accesses to system battery level but a relatively precise value is sent to the server.

What do you think about that @bfabiszewski ?

from ulogger-android.

stale avatar stale commented on July 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from ulogger-android.

ohhai avatar ohhai commented on July 17, 2024

As for me, there is at least two usecases for this:

  • When sending data to server: allow other people to guess why your phone suddenly turned off.
  • When saving locally: allow you to estimate how specific settings affect battery life and tune them according to this data.

Both cases don't require frequent battery requests: 2..5 min interval is completely fine, as for me.
And this option could be disabled by default and enabled only by people who are ok to spend some extra power budget on it.

from ulogger-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.