Using xml Syntax Highlighting
- <uses-permission android:name="android.permission.WAKE_LOCK" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
Using java Syntax Highlighting
- import android.app.Activity;
- import android.content.Context;
- import android.os.Bundle;
- import android.os.PowerManager;
- public class MyActivity extends Activity {
- protected PowerManager.WakeLock mWakeLock;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(final Bundle icicle) {
- setContentView(R.layout.main);
- /* This code together with the one in onDestroy()
- * will make the screen be always on until this Activity gets destroyed. */
- final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
- this.mWakeLock.acquire();
- }
- @Override
- public void onDestroy() {
- this.mWakeLock.release();
- super.onDestroy();
- }
- }
Parsed in 0.090 seconds, using GeSHi 1.0.8.4
See:
http://code.google.com/android/referenc ... nager.html for further details.Works with: SDK v1.0







