我从来没有做过太多的 Java 编程,大部分都是 PHP / RUBY / Javascript,所以我不完全确定如何访问wLock.release()
from onDestroy
?
public class SlammedNavigatorActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "SN Wake Lock");
wLock.acquire();
}
public void onDestroy() {
wLock.release();
}
}