Comments (3)
The behavior of isCharging()
is a little wonky (as tested on API 25). It appears that even if the battery status is 2 (Charging) and the device is on AC, isCharging will not return true unless the battery level has actually incremented (e.g. via adb shell dumpsys battery set level 50 && adb shell dumpsys battery set level 51
). At very least, this should be documented in the lesson notes.
Also, if you fall back to the sticky broadcast intent, this relies instead on the battery charging status set e.g. via adb shell dumpsys battery set status 2
.
In any case, the two methods for determining charging status in API >= 23 and API < 23 presented in the lesson are not equivalent. They are also different than checking whether the device is plugged in, i.e. they do not correspond to ACTION_POWER_CONNECTED
and ACTION_POWER_DISCONNECTED
as is implied in the lesson.
from ud851-exercises.
In the BatteryManager document, the isCharging()
method was described as below.
Return true if the battery is currently considered to be charging. This means that the device is plugged in and is supplying sufficient power that the battery level is going up (or the battery is fully charged).
Therefore, what lid said was right. The isCharging()
method only returns true when the battery level has actually incremented. I think the Android Framework team considered the situation that the device was plugged in some insufficient power. It usually happens when the device is charging using a power bank or through a car USB port.
from ud851-exercises.
Closing this issue as it is not related to the repo's code.
from ud851-exercises.
Related Issues (20)
- T10.05-ChargingBroadcastReceiver TODO (1) Typo
- T10.06-Exercise-StickyBroadcastForCharging
- T05a.02 CharSequence conversion is not needed
- Why do I get this “Context = NullPointerException” error in my homework?
- Lesson01-Favorite-Toys Outdated targetSDK
- source code is outdated HOT 2
- Lesson 2, Exercise 1 has some dependency issues HOT 1
- Lesson T03.01 Exercise and Solution missing number_list_item.xml HOT 1
- S03.01-Exercise-RecyclerViewLayout: ForecastAdapter.java is missing.
- T03.01 exercise and solution missing resource file number_list_item.xml HOT 3
- T03.01-Exercise-RecyclerViewLayout - conflicting name between Main activity and xml rescources HOT 3
- Gradle Failed HOT 2
- Default Activity not found
- download haltes HOT 1
- T05b.03-Solution-PolishAsyncTask
- T01.03-Exercise-AddScrolling-into FrameLayout HOT 3
- Designer editor is unavailable until next gradle sync
- Unable to sync projects in my android studio HOT 1
- Notificaiton image not showing up T10.02
- Unable to sync projects in my android studio 4.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ud851-exercises.