snlove / beginning-android-games

Automatically exported from code.google.com/p/beginning-android-games
0 stars 0 forks source link

[Chapter 4] Adding Wake Locks to the full-screen example as suggested in the book. #47

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Add the contents of «Using Wake Locks» to the full-screen example.
1. Add this lines into onCreate method (same after or before seting content 
view):
PowerManager powerManager =
      (PowerManager)context.getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, 
       "My Lock");

2. Add «wakeLock.acquire();» and «wakeLock.release();» lines into onResume 
and onPause methods respectively.

What is the expected output? What do you see instead?
It doesn't works. Eclipse underline first «context» word and shows de error 
«context cannot be resolved».

What version of the product are you using? On what operating system?

Please provide any additional information below.
It's solved without «context.» in that line.

Original issue reported on code.google.com by kikeca...@gmail.com on 2 Jan 2012 at 9:41