Right at the acquire()
it fails. Eclipse doesn't say what the error was. It just stops the execution on my emulator and gives me that "Class File Editor" "Source not found" display.
public class MyAppActivity extends Activity {
private PowerManager pManager;
private PowerManager.WakeLock wakeLock;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.main);
allocStructs();
}
private void allocStructs() {
// I've tried this with "getBaseContext()" and with "this"
// same results. I get a pManager and a wakeLock
// Then it crashes when I attempt to acquire
pManager = (PowerManager)getBaseContext().getSystemService(
Context.POWER_SERVICE);
wakeLock = pManager.newWakeLock(
PowerManager.FULL_WAKE_LOCK, "full");
}
public void onWakeLockButtonClicked(View view) {
boolean checked = ((RadioButton) view).isChecked();
if (!checked) {
return;
}
if (!wakeLock.isHeld()) {
wakeLock.acquire(); // fails here
}
}
}