我從來沒有做過太多的Java編程,主要是所有的PHP/RUBY/Javascript,所以我不完全確定如何可能去訪問wLock.release()
從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();
}
}