Code Monkey home page Code Monkey logo

Comments (9)

philips77 avatar philips77 commented on June 5, 2024 2

Well, that's understandable. Older versions don't have offloaded scanning, they have to run the service and even filter devices using CPU. I would even say, that for long lasting scanning the minimum Android version should be 8, where the option with Pending Intent was added. On older phones it is not possible to have all the features: background scanning, quick responses, filtering, and good battery lifetime.

from android-scanner-compat-library.

ndrjt avatar ndrjt commented on June 5, 2024

Hi @schlachtzeuger,
I am facing the same issue, even I have used pendingintent for background scan for a while but it scanning for around 30 mins. is there any way to scan continuously for hours and hours?

Thanks.

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

I think the design is to prevent the battery from dying. You may have a Task in TaskManager that will start and stop scanning every now and then if you really need to.

from android-scanner-compat-library.

ndrjt avatar ndrjt commented on June 5, 2024

Yeah, what if I need to scan continuously? And how we can achieve it by library?

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

The goal of the library is to mimic the behavior of the latest Android version on older phones. I'm rather thinking of focusing on saving battery for pre-Oreo phones, than on allowing long lasting continuous scan for newer.

from android-scanner-compat-library.

indrajit9 avatar indrajit9 commented on June 5, 2024

Thank you @philips77

from android-scanner-compat-library.

schlachtzeuger avatar schlachtzeuger commented on June 5, 2024

@ndrjt : After reading my request I'm not sure if I explained my issue comprehensible: My issue is not that it stops after some time but that it literally kills the battery on older Android versions.

from android-scanner-compat-library.

schlachtzeuger avatar schlachtzeuger commented on June 5, 2024

That's exactly why I was asking if we could throttle background scanning on pre-Oreo devices a bit. Thus we could have some sort of background scanning, maybe with a higher delay but without killing the battery.

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

There is this method to trim scan and rest intervals:

/**
* Pre-Lollipop scanning requires a wakelock and the CPU cannot go to sleep.
* To conserve power we can optionally scan for a certain duration (scan interval)
* and then rest for a time before starting scanning again. Won't affect Lollipop
* or later devices.
*
* @param scanInterval interval in ms to scan at a time.
* @param restInterval interval to sleep for without scanning before scanning again for
* scanInterval.
*/
@NonNull
public Builder setPowerSave(final long scanInterval, final long restInterval) {
if (scanInterval <= 0 || restInterval <= 0) {
throw new IllegalArgumentException("scanInterval and restInterval must be > 0");
}
powerSaveScanInterval = scanInterval;
powerSaveRestInterval = restInterval;
return this;
}

I'm closing the issue due to inactivity. Sorry that it took me so long to reply.

from android-scanner-compat-library.

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.