8

I have this code:

wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
            | PowerManager.ON_AFTER_RELEASE, "MyWakeLock");

And the FULL_WAKE_LOCK is crossed out and it's saying "PowerManger.FULL_WAKE_LOCK is deprecated". The code is working. But what does it mean exactly? And can it evoke any problems?

user000001
  • 32,226
  • 12
  • 81
  • 108
silvia_aut
  • 1,481
  • 6
  • 19
  • 33

4 Answers4

3

Deprecation means that the feature may be removed in future versions of Android, or that an alternative has been added. It's not removed immediately to ensure backwards compatibility and to give you time to comply with the new standard.

Which is, according to the documentation:

"Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission."

So it won't cause any problems now, but in future versions of Android, it may. You can read more about deprecation here.

ashatte
  • 5,442
  • 8
  • 39
  • 50
2

You can find more information about it by clicking here. It has everything detailed about what feature does. It won't cause any problems for the current versions but in the future It might.

Shaun
  • 388
  • 3
  • 13
0

PowerManager.FULL_WAKE_LOCK

This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.

Wake lock level: Ensures that the screen and keyboard backlight are on at full brightness.

If the user presses the power button, then the FULL_WAKE_LOCK will be implicitly released by the system, causing both the screen and the CPU to be turned off. Contrast with PARTIAL_WAKE_LOCK.

Mukesh Kumar Singh
  • 4,512
  • 2
  • 22
  • 30
0

According to Wikipedia,

Deprecated means "You can still use this, but don't count on it, because we will probably replace it with something else (or remove it entirely) in future software releases."

In general terms it means that there is a better way of doing this, and the deprecated method should be avoided. Moreover, deprecated methods are not backward compatible too, and are likely to be removed in future versions.

On Developer website it is clearly mentioned

"Device battery life will be significantly affected by the use of this API. Do not acquire PowerManager.WakeLocks unless you really need them, use the minimum levels possible, and be sure to release them as soon as possible."

User0911
  • 1,552
  • 5
  • 22
  • 33