Java Code Examples for android.os.PowerManager

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AlarmApp-Android, under directory /src/com/google/android/c2dm/.

Source file: C2DMBaseReceiver.java

  32 
vote

/** 
 * Called from the broadcast receiver. Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service alive.
 */
static void runIntentInService(Context context,Intent intent){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
  }
  mWakeLock.acquire();
  Log.i(TAG,"runIntentInService");
  String receiver=context.getPackageName() + ".C2DMReceiver";
  intent.setClassName(context,receiver);
  context.startService(intent);
}
 

Example 2

From project android-context, under directory /src/edu/fsu/cs/contextprovider/wakeup/.

Source file: WakefulIntentService.java

  32 
vote

synchronized private static PowerManager.WakeLock getLock(Context context){
  if (lockStatic == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    lockStatic=mgr.newWakeLock(PowerManager.FULL_WAKE_LOCK,LOCK_NAME_STATIC);
    lockStatic.setReferenceCounted(true);
  }
  return (lockStatic);
}
 

Example 3

From project android-tether, under directory /c2dm/com/google/android/c2dm/.

Source file: C2DMBaseReceiver.java

  32 
vote

/** 
 * Called from the broadcast receiver.  Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service  alive. 
 */
static void runIntentInService(Context context,Intent intent){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
  }
  mWakeLock.acquire();
  ContextWrapper cwrap=(ContextWrapper)context;
  String receiver=cwrap.getBaseContext().getClass().getPackage().getName() + ".C2DMReceiver";
  intent.setClassName(context,receiver);
  context.startService(intent);
}
 

Example 4

From project android_7, under directory /src/org/immopoly/android/c2dm/.

Source file: C2DMBaseReceiver.java

  32 
vote

/** 
 * Called from the broadcast receiver. Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service alive.
 */
static void runIntentInService(Context context,Intent intent){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
  }
  mWakeLock.acquire();
  intent.setClassName(context,C2DMReceiver.class.getName());
  context.startService(intent);
}
 

Example 5

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/bluetooth/.

Source file: DockEventReceiver.java

  32 
vote

/** 
 * Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.
 */
public static void beginStartingService(Context context,Intent intent){
synchronized (mStartingServiceSync) {
    if (mStartingService == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      mStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"StartingDockService");
    }
    mStartingService.acquire(WAKELOCK_TIMEOUT);
    if (context.startService(intent) == null) {
      Log.e(TAG,"Can't start DockService");
    }
  }
}
 

Example 6

From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.

Source file: CellBroadcastAlertAudio.java

  32 
vote

@Override public void onCreate(){
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  mWakeLock.acquire();
  mVibrator=(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  mTelephonyManager=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  mTelephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
}
 

Example 7

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: ExchangeService.java

  32 
vote

private void acquireWakeLock(long id){
synchronized (mWakeLocks) {
    Boolean lock=mWakeLocks.get(id);
    if (lock == null) {
      if (mWakeLock == null) {
        PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
        mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MAIL_SERVICE");
        mWakeLock.acquire();
      }
      mWakeLocks.put(id,true);
    }
  }
}
 

Example 8

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: GridLayer.java

  32 
vote

public void startSlideshow(){
  endSlideshow();
  mSlideshowMode=true;
  mZoomValue=1.0f;
  centerCameraForSlot(mInputProcessor.getCurrentSelectedSlot(),1.0f);
  mTimeElapsedSinceView=SLIDESHOW_TRANSITION_TIME - 1.0f;
  mHud.setAlpha(0);
  PowerManager pm=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,"GridView.Slideshow");
  mWakeLock.acquire();
}
 

Example 9

From project android_packages_apps_VoiceDialer_2, under directory /src/com/android/voicedialer/.

Source file: VoiceDialerActivity.java

  32 
vote

private void acquireWakeLock(Context context){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"VoiceDialer");
    mWakeLock.acquire();
  }
}
 

Example 10

From project andstatus, under directory /src/org/andstatus/app/.

Source file: MyService.java

  32 
vote

private void acquireWakeLock(){
  if (mWakeLock == null) {
    MyLog.d(TAG,"Acquiring wakelock");
    PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
    mWakeLock.acquire();
  }
}
 

Example 11

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: AndTweetService.java

  32 
vote

private PowerManager.WakeLock getWakeLock(){
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  wakeLock.acquire();
  return wakeLock;
}
 

Example 12

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.

Source file: ServerInstrumentation.java

  32 
vote

/** 
 * Attempts to acquire the wake lock.
 * @return a reference to the wake lock, or {@code null} if the wake lockcould not be obtained
 * @see #onStart
 */
@Nullable protected PowerManager.WakeLock tryToAcquireWakeLock(){
  PowerManager powerManager=(PowerManager)getContext().getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock acquiredLock=powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,LOG_TAG);
  try {
    acquiredLock.acquire();
  }
 catch (  SecurityException exception) {
    Log.w(LOG_TAG,"Could not acquire a wake lock for preventing the " + "device from sleeping during testing.",exception);
    acquiredLock=null;
  }
  return acquiredLock;
}
 

Example 13

From project Barcamp-Bangalore-Android-App, under directory /bcb_app/src/com/bangalore/barcamp/gcm/.

Source file: GCMIntentService.java

  32 
vote

static void runIntentInService(Context context,Intent intent){
synchronized (LOCK) {
    if (sWakeLock == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      sWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"my_wakelock");
    }
  }
  sWakeLock.acquire();
  intent.setClassName(context,GCMIntentService.class.getName());
  context.startService(intent);
}
 

Example 14

From project BombusLime, under directory /src/org/bombusim/lime/service/.

Source file: KeepAliveAlarm.java

  32 
vote

@Override public void onReceive(Context context,Intent intent){
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"BombusKeepAlive");
  wakeLock.acquire();
  LimeLog.d("ALARM","KEEP-ALIVE",null);
  context.startService(new Intent(XmppService.ON_KEEP_ALIVE,null,context,XmppService.class));
}
 

Example 15

From project creamed_glacier_app_settings, under directory /src/com/android/settings/bluetooth/.

Source file: DockEventReceiver.java

  32 
vote

/** 
 * Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.
 */
private static void beginStartingService(Context context,Intent intent){
synchronized (sStartingServiceSync) {
    if (sStartingService == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      sStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"StartingDockService");
    }
    sStartingService.acquire();
    if (context.startService(intent) == null) {
      Log.e(TAG,"Can't start DockService");
    }
  }
}
 

Example 16

From project cw-advandroid, under directory /Push/C2DM/src/com/google/android/c2dm/.

Source file: C2DMBaseReceiver.java

  32 
vote

/** 
 * Called from the broadcast receiver.  Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service  alive. 
 */
static void runIntentInService(Context context,Intent intent){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
  }
  mWakeLock.acquire();
  String receiver=context.getPackageName() + ".C2DMReceiver";
  intent.setClassName(context,receiver);
  context.startService(intent);
}
 

Example 17

From project cw-omnibus, under directory /Push/C2DM/src/com/google/android/c2dm/.

Source file: C2DMBaseReceiver.java

  32 
vote

/** 
 * Called from the broadcast receiver.  Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service  alive. 
 */
static void runIntentInService(Context context,Intent intent){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
  }
  mWakeLock.acquire();
  String receiver=context.getPackageName() + ".C2DMReceiver";
  intent.setClassName(context,receiver);
  context.startService(intent);
}
 

Example 18

From project DeskSMS, under directory /DeskSMS/src/com/koushikdutta/desktopsms/.

Source file: WakeLock.java

  32 
vote

static void acquire(Context context){
  release();
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  sWakeLock=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,LOGTAG);
  sWakeLock.acquire();
}
 

Example 19

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/app/wizard/.

Source file: CalibrationWizardActivity.java

  32 
vote

@Override protected void onUserLeaveHint(){
  super.onUserLeaveHint();
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  if (calibrateLightSleepFragment != null) {
    calibrateLightSleepFragment.stopCalibration(this);
  }
  if (checkForScreenBugFragment != null && pm.isScreenOn()) {
    checkForScreenBugFragment.stopCalibration(this);
  }
}
 

Example 20

From project FileExplorer, under directory /src/net/micode/fileexplorer/.

Source file: FTPServerService.java

  32 
vote

private void takeWakeLock(){
  if (wakeLock == null) {
    PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
    if (fullWake) {
      wakeLock=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,WAKE_LOCK_TAG);
    }
 else {
      wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKE_LOCK_TAG);
    }
    wakeLock.setReferenceCounted(false);
  }
  myLog.d("Acquiring wake lock");
  wakeLock.acquire();
}
 

Example 21

From project galaxyCar, under directory /galaxyCar/src/org/psywerx/car/.

Source file: GalaxyCarActivity.java

  32 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,"Sandboc lock");
  mWakeLock.acquire();
  init();
}
 

Example 22

From project GCM-Demo, under directory /gcm/gcm-client/src/com/google/android/gcm/.

Source file: GCMBaseIntentService.java

  32 
vote

/** 
 * Called from the broadcast receiver. <p> Will process the received intent, call handleMessage(), registered(), etc. in background threads, with a wake lock, while keeping the service alive.
 */
static void runIntentInService(Context context,Intent intent,String className){
synchronized (LOCK) {
    if (sWakeLock == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      sWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_KEY);
    }
  }
  Log.v(TAG,"Acquiring wakelock");
  sWakeLock.acquire();
  intent.setClassName(context,className);
  context.startService(intent);
}
 

Example 23

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/service/.

Source file: AndroidHeartBeatService.java

  32 
vote

public AndroidHeartBeatService(Context context){
  mContext=context;
  mAlarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  PowerManager powerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mWakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_TAG);
  mAlarms=new SparseArray<Alarm>();
}
 

Example 24

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.

Source file: BackgroundService.java

  32 
vote

@Override protected void onPreExecute(){
  final PowerManager powerManager=(PowerManager)getSystemService(Context.POWER_SERVICE);
  this.wakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,BackgroundService.TAG);
  wakeLock.acquire();
  super.onPreExecute();
}
 

Example 25

From project Gmote, under directory /gmoteclient/src/org/gmote/client/android/.

Source file: ActivityUtil.java

  32 
vote

public void onStart(Activity activity){
  mActivity=activity;
  if (wifiLock == null) {
    PowerManager powerManager=(PowerManager)mActivity.getSystemService(Context.POWER_SERVICE);
    wakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,DEBUG_TAG);
    wakeLock.setReferenceCounted(true);
    WifiManager wifiManager=(WifiManager)mActivity.getSystemService(Context.WIFI_SERVICE);
    wifiLock=wifiManager.createWifiLock(DEBUG_TAG);
    wifiLock.setReferenceCounted(true);
  }
  Log.e(mActivity.getClass().getName(),"ACQUIRE");
  wifiLock.acquire();
  wakeLock.acquire();
}
 

Example 26

From project groundhog-reader, under directory /src/main/java/com/almarsoft/GroundhogReader/.

Source file: GroupMessagesDownloadDialog.java

  32 
vote

public GroupMessagesDownloadDialog(ServerManager manager,Context context){
  mServerManager=manager;
  mContext=context;
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"GroundhogDownloading");
}
 

Example 27

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/logger/.

Source file: GPSLoggerService.java

  32 
vote

private void updateWakeLock(){
  if (this.mLoggingState == Constants.LOGGING) {
    PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener);
    PowerManager pm=(PowerManager)this.getSystemService(Context.POWER_SERVICE);
    this.mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
    this.mWakeLock.acquire();
  }
 else {
    if (this.mWakeLock != null) {
      this.mWakeLock.release();
      this.mWakeLock=null;
    }
  }
}
 

Example 28

From project liquidroid, under directory /src/liqui/droid/util/.

Source file: InfiniteWakelockIntentService.java

  32 
vote

synchronized private static PowerManager.WakeLock getLock(Context context){
  if (lockStatic == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,NAME);
    lockStatic.setReferenceCounted(true);
  }
  return (lockStatic);
}
 

Example 29

From project mediautilities, under directory /src/ac/robinson/util/.

Source file: UIUtilities.java

  32 
vote

public static PowerManager.WakeLock acquireWakeLock(Activity activity,String tag){
  PowerManager powerManager=(PowerManager)activity.getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock wakeLock=powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,tag);
  wakeLock.acquire();
  return wakeLock;
}
 

Example 30

From project MobiPerf, under directory /android/src/com/mobiperf/util/.

Source file: PhoneUtils.java

  32 
vote

/** 
 * Wakes up the CPU of the phone if it is sleeping. 
 */
public synchronized void acquireWakeLock(){
  if (wakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"tag");
  }
  Logger.d("PowerLock acquired");
  wakeLock.acquire();
}
 

Example 31

From project ohmagePhone, under directory /src/org/ohmage/service/.

Source file: WakefulService.java

  32 
vote

synchronized private static PowerManager.WakeLock getLock(Context context){
  if (lockStatic == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,NAME);
    lockStatic.setReferenceCounted(true);
  }
  return (lockStatic);
}
 

Example 32

From project Ohmage_Phone, under directory /src/org/ohmage/service/.

Source file: SurveyGeotagService.java

  32 
vote

@Override public void onCreate(){
  super.onCreate();
  updateCounter=0;
  mLocManager=(LocationManager)getSystemService(LOCATION_SERVICE);
  mLocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,UPDATE_FREQ,0,mLocationListener);
  mLocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,UPDATE_FREQ,0,mLocationListener);
  mAlarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
  Intent intentToFire=new Intent(SurveyGeotagTimeoutReceiver.ACTION_GEOTAG_TIMEOUT_ALARM);
  PendingIntent pendingIntent=PendingIntent.getBroadcast(this.getApplicationContext(),0,intentToFire,0);
  mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + LOCATION_STALENESS_LIMIT,pendingIntent);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wl=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  wl.acquire();
}
 

Example 33

From project onebusaway-android, under directory /src/com/joulespersecond/seattlebusbot/.

Source file: AlarmReceiver.java

  32 
vote

@Override public void onReceive(Context context,Intent intent){
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  PowerManager.WakeLock lock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  lock.acquire(10 * 1000);
  Intent tripService=new Intent(context,TripService.class);
  tripService.setAction(intent.getAction());
  tripService.setData(intent.getData());
  context.startService(tripService);
}
 

Example 34

From project OneMoreDream, under directory /src/com/dixheure/.

Source file: AlarmAlertWakeLock.java

  32 
vote

static void acquireCpuWakeLock(Context context){
  Log.v("Acquiring cpu wake lock");
  if (sCpuWakeLock != null) {
    return;
  }
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  sCpuWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,Log.LOGTAG);
  sCpuWakeLock.acquire();
}
 

Example 35

From project packages_apps_Calendar, under directory /src/com/android/calendar/alerts/.

Source file: AlertReceiver.java

  32 
vote

/** 
 * Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.
 */
public static void beginStartingService(Context context,Intent intent){
synchronized (mStartingServiceSync) {
    if (mStartingService == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      mStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"StartingAlertService");
      mStartingService.setReferenceCounted(false);
    }
    mStartingService.acquire();
    context.startService(intent);
  }
}
 

Example 36

From project parandroid, under directory /src/com/rabenauge/parandroid/.

Source file: Launcher.java

  32 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wl=pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,"ScreenBrightKeyboardOff");
  demo=new Demo(this);
  preview=new Preview(this,demo);
  setContentView(demo);
}
 

Example 37

From project platform_frameworks_policies_base, under directory /mid/com/android/internal/policy/impl/.

Source file: MidWindowManager.java

  32 
vote

/** 
 * {@inheritDoc} 
 */
public void init(Context context,IWindowManager windowManager,LocalPowerManager powerManager){
  mContext=context;
  mWindowManager=windowManager;
  mPowerManager=powerManager;
  mHandler=new Handler();
  mShortcutManager=new ShortcutManager(context,mHandler);
  mShortcutManager.observe();
  mHomeIntent=new Intent(Intent.ACTION_MAIN,null);
  mHomeIntent.addCategory(Intent.CATEGORY_HOME);
  mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mBroadcastWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MidWindowManager.mBroadcastWakeLock");
}
 

Example 38

From project platform_packages_apps_alarmclock, under directory /src/com/android/alarmclock/.

Source file: AlarmAlertWakeLock.java

  32 
vote

static void acquireCpuWakeLock(Context context){
  Log.v("Acquiring cpu wake lock");
  if (sCpuWakeLock != null) {
    return;
  }
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  sCpuWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,Log.LOGTAG);
  sCpuWakeLock.acquire();
}
 

Example 39

From project platform_packages_apps_calendar, under directory /src/com/android/calendar/alerts/.

Source file: AlertReceiver.java

  32 
vote

/** 
 * Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.
 */
public static void beginStartingService(Context context,Intent intent){
synchronized (mStartingServiceSync) {
    if (mStartingService == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      mStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"StartingAlertService");
      mStartingService.setReferenceCounted(false);
    }
    mStartingService.acquire();
    context.startService(intent);
  }
}
 

Example 40

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/vcard/.

Source file: ImportVCardActivity.java

  32 
vote

public VCardCacheThread(final Uri[] sourceUris){
  mSourceUris=sourceUris;
  mSource=null;
  final Context context=ImportVCardActivity.this;
  final PowerManager powerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mWakeLock=powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,LOG_TAG);
  mDisplayName=null;
}
 

Example 41

From project platform_packages_apps_im, under directory /src/com/android/im/service/.

Source file: AndroidHeartBeatService.java

  32 
vote

public AndroidHeartBeatService(Context context){
  mContext=context;
  mAlarmManager=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  PowerManager powerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mWakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,WAKELOCK_TAG);
  mAlarms=new SparseArray<Alarm>();
}
 

Example 42

From project platform_packages_apps_mms, under directory /src/com/android/mms/transaction/.

Source file: NotificationPlayer.java

  32 
vote

/** 
 * We want to hold a wake lock while we do the prepare and play.  The stop probably is optional, but it won't hurt to have it too.  The problem is that if you start a sound while you're holding a wake lock (e.g. an alarm starting a notification), you want the sound to play, but if the CPU turns off before mThread gets to work, it won't.  The simplest way to deal with this is to make it so there is a wake lock held while the thread is starting or running.  You're going to need the WAKE_LOCK permission if you're going to call this. This must be called before the first time play is called.
 * @hide
 */
public void setUsesWakeLock(Context context){
  if (mWakeLock != null || mThread != null) {
    throw new RuntimeException("assertion failed mWakeLock=" + mWakeLock + " mThread="+ mThread);
  }
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,mTag);
}
 

Example 43

From project platform_packages_apps_phone, under directory /src/com/android/phone/.

Source file: CallerInfoCache.java

  32 
vote

/** 
 * Call  {@link PowerManager.WakeLock#acquire} and call {@link AsyncTask#execute(Object)}, guaranteeing the lock is held during the asynchronous task.
 */
public void acquireWakeLockAndExecute(){
  PowerManager pm=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,LOG_TAG);
  mWakeLock.acquire();
  execute();
}
 

Example 44

From project platform_packages_apps_settings, under directory /src/com/android/settings/bluetooth/.

Source file: DockEventReceiver.java

  32 
vote

/** 
 * Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.
 */
private static void beginStartingService(Context context,Intent intent){
synchronized (sStartingServiceSync) {
    if (sStartingService == null) {
      PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
      sStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"StartingDockService");
    }
    sStartingService.acquire();
    if (context.startService(intent) == null) {
      Log.e(TAG,"Can't start DockService");
    }
  }
}
 

Example 45

From project platform_packages_apps_voicedialer, under directory /src/com/android/voicedialer/.

Source file: VoiceDialerActivity.java

  32 
vote

private void acquireWakeLock(Context context){
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"VoiceDialer");
    mWakeLock.acquire();
  }
}
 

Example 46

From project platform_packages_providers_calendarprovider, under directory /src/com/android/providers/calendar/.

Source file: CalendarAlarmManager.java

  32 
vote

PowerManager.WakeLock getScheduleNextAlarmWakeLock(){
  if (mScheduleNextAlarmWakeLock == null) {
    PowerManager powerManager=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
    mScheduleNextAlarmWakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,SCHEDULE_NEXT_ALARM_WAKE_LOCK);
    mScheduleNextAlarmWakeLock.setReferenceCounted(true);
  }
  return mScheduleNextAlarmWakeLock;
}
 

Example 47

From project roman10-android-tutorial, under directory /pagedview/src/roman10/imageviewer/.

Source file: Viewer2.java

  32 
vote

@Override public void onResume(){
  super.onResume();
  checkKeyguard();
  if (mWakeLock != null) {
    if (mWakeLock.isHeld()) {
      mWakeLock.release();
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,"Viewer");
  mWakeLock.acquire();
  SettingsStatic.setAlarmCleanup(mContext,0);
}
 

Example 48

From project SASAbus, under directory /src/it/sasabz/android/sasabus/classes/.

Source file: FileRetriever.java

  32 
vote

/** 
 * This constructor takes an activity, a dbZipFile to store the  downloaded Zip file, a dbFile to store the unzipped database and at least a md5File to save the downloaded md5File
 * @param activity is the actual activity
 * @param dbZIPFile is the file to save the downloaded zip file
 * @param dbFile is the file to save the unzipped db file
 * @param md5File is the file to save the downloaded md5 file
 */
public FileRetriever(CheckDatabaseActivity activity,String filename){
  super();
  this.filename=filename;
  this.activity=activity;
  this.res=activity.getResources();
  PowerManager pm=(PowerManager)this.activity.getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,TAG);
  originalRequestedOrientation=activity.getRequestedOrientation();
  activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
  wakeLock.acquire();
}
 

Example 49

From project SMSSync, under directory /smssync/src/org/addhen/smssync/services/.

Source file: SmsSyncServices.java

  32 
vote

synchronized private static PowerManager.WakeLock getPhoneWakeLock(Context context){
  if (mStartingService == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mStartingService=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,CLASS_TAG);
  }
  return mStartingService;
}
 

Example 50

From project sonet, under directory /core/src/com/piusvelte/sonet/core/.

Source file: Sonet.java

  32 
vote

public static void acquire(Context context){
  if (hasLock())   sWakeLock.release();
  PowerManager pm=(PowerManager)context.getSystemService(POWER_SERVICE);
  sWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  sWakeLock.acquire();
}
 

Example 51

From project Speedometer, under directory /android/src/com/google/wireless/speed/speedometer/util/.

Source file: PhoneUtils.java

  32 
vote

/** 
 * Wakes up the CPU of the phone if it is sleeping. 
 */
public synchronized void acquireWakeLock(){
  if (wakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"tag");
  }
  Logger.d("PowerLock acquired");
  wakeLock.acquire();
}
 

Example 52

From project sthlmtraveling, under directory /src/com/markupartist/sthlmtraveling/service/.

Source file: WakefulIntentService.java

  32 
vote

synchronized private static PowerManager.WakeLock getLock(Context context){
  Log.d(TAG,"About to get lock");
  if (lockStatic == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,LOCK_NAME_STATIC);
    lockStatic.setReferenceCounted(true);
  }
  return (lockStatic);
}
 

Example 53

From project SyncMyPix, under directory /src/com/nloko/android/syncmypix/.

Source file: SyncWakeLock.java

  32 
vote

public static void acquireWakeLock(Context context){
  if (context == null) {
    return;
  }
  if (mWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"SyncMyPix WakeLock");
    mWakeLock.acquire();
  }
}
 

Example 54

From project TextSecure, under directory /src/org/thoughtcrime/securesms/service/.

Source file: MmscProcessor.java

  32 
vote

public MmscProcessor(Context context){
  this.context=context;
  PowerManager powerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  this.connectivityManager=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  this.wakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MMS Connection");
  this.wakeLock.setReferenceCounted(false);
}
 

Example 55

From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/services/.

Source file: SyncServices.java

  32 
vote

synchronized private static PowerManager.WakeLock getPhoneWakeLock(Context context){
  if (mStartingService == null) {
    PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    mStartingService=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,CLASS_TAG);
  }
  return mStartingService;
}
 

Example 56

From project adg-android, under directory /src/com/analysedesgeeks/android/os_service/.

Source file: PodcastPlaybackService.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  mAudioManager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(),MediaButtonIntentReceiver.class.getName()));
  mPlayer=new MultiPlayer();
  mPlayer.setHandler(mMediaplayerHandler);
  final IntentFilter commandFilter=new IntentFilter();
  commandFilter.addAction(SERVICECMD);
  commandFilter.addAction(TOGGLEPAUSE_ACTION);
  commandFilter.addAction(PAUSE_ACTION);
  registerReceiver(mIntentReceiver,commandFilter);
  final PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  mWakeLock.setReferenceCounted(false);
  final Message msg=mDelayedStopHandler.obtainMessage();
  mDelayedStopHandler.sendMessageDelayed(msg,IDLE_DELAY);
}
 

Example 57

From project android-pedometer, under directory /src/name/bagi/levente/pedometer/.

Source file: StepService.java

  31 
vote

private void acquireWakeLock(){
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  int wakeFlags;
  if (mPedometerSettings.wakeAggressively()) {
    wakeFlags=PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP;
  }
 else   if (mPedometerSettings.keepScreenOn()) {
    wakeFlags=PowerManager.SCREEN_DIM_WAKE_LOCK;
  }
 else {
    wakeFlags=PowerManager.PARTIAL_WAKE_LOCK;
  }
  wakeLock=pm.newWakeLock(wakeFlags,TAG);
  wakeLock.acquire();
}
 

Example 58

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: VideoCallActivity.java

  31 
vote

public void onCreate(Bundle savedInstanceState){
  launched=true;
  Log.d("onCreate VideoCallActivity");
  super.onCreate(savedInstanceState);
  setContentView(R.layout.videocall);
  mVideoView=(SurfaceView)findViewById(R.id.video_surface);
  LinphoneCore lc=LinphoneManager.getLc();
  lc.setVideoWindow(mVideoView);
  mVideoCaptureView=(SurfaceView)findViewById(R.id.video_capture_surface);
  recordManager=AndroidCameraRecordManager.getInstance();
  recordManager.setOnCapturingStateChanged(this);
  recordManager.setSurfaceView(mVideoCaptureView);
  mVideoCaptureView.setZOrderOnTop(true);
  if (!recordManager.isMuted())   LinphoneManager.getInstance().sendStaticImage(false);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,Log.TAG);
  mWakeLock.acquire();
  fixScreenOrientationForOldDevices();
}
 

Example 59

From project callmeter, under directory /src/de/ub0r/android/callmeter/data/.

Source file: LogRunnerService.java

  31 
vote

/** 
 * Acquire  {@link WakeLock} and init service.
 * @param a action
 * @return {@link WakeLock}
 */
private WakeLock acquire(final String a){
  final PowerManager pm=(PowerManager)this.getSystemService(Context.POWER_SERVICE);
  final PowerManager.WakeLock wakelock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  wakelock.acquire();
  Log.i(TAG,"got wakelock");
  if (a != null && (a.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED) || a.equals(ACTION_SMS))) {
    Log.i(TAG,"sleep for " + WAIT_FOR_LOGS + "ms");
    try {
      Thread.sleep(WAIT_FOR_LOGS);
    }
 catch (    InterruptedException e) {
      Log.e(TAG,"interrupted while waiting for logs",e);
    }
  }
  TelephonyManager tm=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
  roaming=tm.isNetworkRoaming();
  Log.d(TAG,"roaming: " + roaming);
  mynumber=tm.getLine1Number();
  Log.d(TAG,"my number: " + mynumber);
  return wakelock;
}
 

Example 60

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: CHMIWidgetProvider.java

  31 
vote

@Override public void onReceive(Context context,Intent intent){
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  WakeLock wl=pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,"Refresh chmi widget");
  try {
    wl.acquire();
    super.onReceive(context,intent);
    if (MY_WIDGET_UPDATE.equals(intent.getAction())) {
      Bundle extras=intent.getExtras();
      if (extras != null) {
        AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
        ComponentName thisAppWidget=new ComponentName(context.getPackageName(),CHMIWidgetProvider.class.getName());
        int[] appWidgetIds=appWidgetManager.getAppWidgetIds(thisAppWidget);
        onUpdate(context,appWidgetManager,appWidgetIds);
      }
    }
  }
  finally {
    if (wl != null) {
      wl.release();
    }
  }
}
 

Example 61

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/am/.

Source file: ActivityStack.java

  31 
vote

ActivityStack(ActivityManagerService service,Context context,boolean mainStack,boolean cornerstonePanelStack,int cornerstonePanelIndex){
  mService=service;
  mContext=context;
  mMainStack=mainStack;
  PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mGoingToSleep=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"ActivityManager-Sleep");
  mLaunchingActivity=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"ActivityManager-Launch");
  mLaunchingActivity.setReferenceCounted(false);
  if (!mMainStack && !cornerstonePanelStack) {
    mStackName="Cornerstone_Stack";
    mCornerstoneStack=true;
    mCornerstonePanelStack=false;
    mCornerstonePanelIndex=-1;
  }
 else   if (!mMainStack && cornerstonePanelStack) {
    mStackName="CornerstonePanel_Stack:" + cornerstonePanelIndex;
    mCornerstoneStack=false;
    mCornerstonePanelStack=true;
    mCornerstonePanelIndex=cornerstonePanelIndex;
  }
 else {
    mStackName="Main_Stack";
    mCornerstoneStack=false;
    mCornerstonePanelStack=false;
    mCornerstonePanelIndex=-1;
  }
}
 

Example 62

From project fanfoudroid, under directory /src/com/ch_linghu/fanfoudroid/service/.

Source file: TwitterService.java

  31 
vote

@Override public void onCreate(){
  Log.v(TAG,"Server Created");
  super.onCreate();
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  mWakeLock.acquire();
  boolean needCheck=TwitterApplication.mPref.getBoolean(Preferences.CHECK_UPDATES_KEY,false);
  boolean widgetIsEnabled=TwitterService.widgetIsEnabled;
  Log.v(TAG,"Check Updates is " + needCheck + "/wg:"+ widgetIsEnabled);
  if (!needCheck && !widgetIsEnabled) {
    Log.d(TAG,"Check update preference is false.");
    stopSelf();
    return;
  }
  if (!getApi().isLoggedIn()) {
    Log.d(TAG,"Not logged in.");
    stopSelf();
    return;
  }
  schedule(TwitterService.this);
  mNotificationManager=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mNewTweets=new ArrayList<Tweet>();
  mNewMentions=new ArrayList<Tweet>();
  mNewDms=new ArrayList<Dm>();
  if (mRetrieveTask != null && mRetrieveTask.getStatus() == GenericTask.Status.RUNNING) {
    return;
  }
 else {
    mRetrieveTask=new RetrieveTask();
    mRetrieveTask.setListener(mRetrieveTaskListener);
    mRetrieveTask.execute((TaskParams[])null);
  }
}
 

Example 63

From project groundy, under directory /src/main/java/com/codeslap/groundy/.

Source file: DeviceStatus.java

  31 
vote

/** 
 * Register a wake lock to power management in the device
 * @param context Context to use
 * @param awake   if true the device cpu will keep awake untilfalse is called back. if true is passed several times only the first time after a false call will take effect, also if false is passed and previously the cpu was not turned on (true call) does nothing.
 */
public static void keepCpuAwake(Context context,boolean awake){
  if (cpuWakeLock == null) {
    PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
    if (pm != null) {
      cpuWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,TAG);
      cpuWakeLock.setReferenceCounted(true);
    }
  }
  if (cpuWakeLock != null) {
    if (awake) {
      cpuWakeLock.acquire();
      L.d(TAG,"Adquired CPU lock");
    }
 else     if (cpuWakeLock.isHeld()) {
      cpuWakeLock.release();
      L.d(TAG,"Released CPU lock");
    }
  }
}
 

Example 64

From project HabReader, under directory /src/net/meiolania/apps/habrahabr/activities/.

Source file: AbstractionActivity.java

  31 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Preferences preferences=Preferences.getInstance(this);
  if (preferences.getKeepScreen()) {
    PowerManager powerManager=(PowerManager)getSystemService(Context.POWER_SERVICE);
    wakeLock=powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,"wakeLock");
    wakeLock.acquire();
  }
  if (!ConnectionUtils.isConnected(this)) {
    AlertDialog.Builder dialog=new AlertDialog.Builder(this);
    dialog.setTitle(R.string.error);
    dialog.setMessage(getString(R.string.no_connection));
    dialog.setPositiveButton(R.string.close,getConnectionDialogListener());
    dialog.setCancelable(false);
    dialog.show();
  }
}
 

Example 65

From project MicDroid, under directory /src/com/intervigil/micdroid/.

Source file: Mic.java

  31 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Typeface timerFont=Typeface.createFromAsset(getAssets(),"fonts/Clockopia.ttf");
  recordingButton=((ToggleButton)findViewById(R.id.recording_button));
  Button libraryButton=((Button)findViewById(R.id.library_button));
  Button instrumentalButton=((Button)findViewById(R.id.instrumental_button));
  TextView timerDisplay=(TextView)findViewById(R.id.recording_timer);
  recordingButton.setChecked(false);
  recordingButton.setOnCheckedChangeListener(recordBtnListener);
  libraryButton.setOnClickListener(this);
  instrumentalButton.setOnClickListener(this);
  timerDisplay.setTypeface(timerFont);
  timer=new Timer(timerDisplay);
  autotalentTask=new AutotalentTask(Mic.this,postAutotalentTask);
  if (PreferenceHelper.getScreenLock(Mic.this)) {
    PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
    wakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"recordingWakeLock");
  }
  if (UpdateHelper.isAppUpdated(Mic.this)) {
    UpdateHelper.onAppUpdate(Mic.this);
  }
 else {
    AudioHelper.configureRecorder(Mic.this);
  }
}
 

Example 66

From project mixare, under directory /src/org/mixare/.

Source file: MixView.java

  31 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  try {
    handleIntent(getIntent());
    final PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
    getMixViewData().setmWakeLock(pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,"My Tag"));
    killOnError();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    maintainCamera();
    maintainAugmentR();
    maintainZoomBar();
    if (!isInited) {
      setdWindow(new PaintScreen());
      setDataView(new DataView(getMixViewData().getMixContext()));
      setZoomLevel();
      isInited=true;
    }
    SharedPreferences settings=getSharedPreferences(PREFS_NAME,0);
    if (settings.getBoolean("firstAccess",false) == false) {
      firstAccess(settings);
    }
  }
 catch (  Exception ex) {
    doError(ex);
  }
}
 

Example 67

From project mp3tunes-android, under directory /src/com/mp3tunes/android/service/.

Source file: Mp3tunesService.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mNm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  mBufferPercent=0;
  setForeground(true);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MP3tunes Player");
  WifiManager wm=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiLock=wm.createWifiLock("MP3tunes Player");
  mTelephonyManager=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
  mTelephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  mTrackHistory=new Stack<Integer>();
  mLocker=(Locker)MP3tunesApplication.getInstance().map.get("mp3tunes_locker");
  try {
    mDb=new LockerDb(this,null);
  }
 catch (  Exception ex) {
    System.out.println(ex.getMessage());
    ex.printStackTrace();
    mServiceState=STATE.STOPPED;
    notifyChange(DATABASE_ERROR);
    mNm.cancel(NOTIFY_ID);
    if (mWakeLock.isHeld())     mWakeLock.release();
    if (mWifiLock.isHeld())     mWifiLock.release();
  }
}
 

Example 68

From project No-Pain-No-Game, under directory /src/edu/ucla/cs/nopainnogame/pedometer/.

Source file: StepService.java

  31 
vote

private void acquireWakeLock(){
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  int wakeFlags;
  if (mPedometerSettings.wakeAggressively()) {
    wakeFlags=PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP;
  }
 else   if (mPedometerSettings.keepScreenOn()) {
    wakeFlags=PowerManager.SCREEN_DIM_WAKE_LOCK;
  }
 else {
    wakeFlags=PowerManager.PARTIAL_WAKE_LOCK;
  }
  wakeLock=pm.newWakeLock(wakeFlags,TAG);
  wakeLock.acquire();
}
 

Example 69

From project openpomo, under directory /src/it/unibz/pomodroid/.

Source file: Pomodoro.java

  31 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.pomodoro);
  this.pomodoroSecondsValue=getUser().getPomodoroMinutesDuration() * SECONDS_PER_MINUTE;
  this.pomodoroSecondsLength=this.pomodoroSecondsValue;
  this.selectedActivity=getUser().getSelectedActivity();
  updateProgressbarAndTimer(pomodoroSecondsValue);
  TextView atvActivitySummary=(TextView)findViewById(R.id.atvActivitySummary);
  atvActivitySummary.setText(selectedActivity.getSummary() + " (" + selectedActivity.getStringDeadline()+ ")");
  TextView atvActivityDescription=(TextView)findViewById(R.id.atvActivityDescription);
  atvActivityDescription.setText(selectedActivity.getDescription() + " (Given by: " + selectedActivity.getReporter()+ ")");
  TextView atvActivityNumberPomodoro=(TextView)findViewById(R.id.atvActivityNumberPomodoro);
  Integer numberPomodoro=selectedActivity.getNumberPomodoro();
  atvActivityNumberPomodoro.setText("Number of pomodoro: " + numberPomodoro.toString());
  TextView TextViewActivityNumberInterruptions=(TextView)findViewById(R.id.atvActivityNumberInterruptions);
  Integer numberInterruptions=0;
  numberInterruptions=selectedActivity.getNumberInterruptions();
  TextViewActivityNumberInterruptions.setText("Number of interruptions: " + numberInterruptions.toString());
  PowerManager powerManager=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK,"DoNotDimScreen");
  this.originalBrightness=getWindow().getAttributes().screenBrightness;
}
 

Example 70

From project packages_apps_BlackICEControl, under directory /src/com/blackice/control/fragments/.

Source file: DensityChanger.java

  31 
vote

@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,Preference preference){
  if (preference == mReboot) {
    PowerManager pm=(PowerManager)getActivity().getSystemService(Context.POWER_SERVICE);
    pm.reboot("Resetting density");
    return true;
  }
 else   if (preference == mClearMarketData) {
    new ClearMarketDataTask().execute("");
    return true;
  }
 else   if (preference == mOpenMarket) {
    Intent openMarket=new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ComponentName activityName=openMarket.resolveActivity(getActivity().getPackageManager());
    if (activityName != null) {
      mContext.startActivity(openMarket);
    }
 else {
      preference.setSummary("Coulnd't open the market! If you're sure it's installed, open it yourself from the launcher.");
    }
    return true;
  }
  return super.onPreferenceTreeClick(preferenceScreen,preference);
}
 

Example 71

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: EmergencyCallHelper.java

  31 
vote

/** 
 * Actual implementation of startEmergencyCallFromAirplaneModeSequence(), guaranteed to run on the handler thread.
 * @see startEmergencyCallFromAirplaneModeSequence()
 */
private void startSequenceInternal(Message msg){
  if (DBG)   log("startSequenceInternal(): msg = " + msg);
  cleanup();
  mNumber=(String)msg.obj;
  if (DBG)   log("- startSequenceInternal: Got mNumber: '" + mNumber + "'");
  mNumRetriesSoFar=0;
  mPhone=mApp.mCM.getDefaultPhone();
  PowerManager pm=(PowerManager)mApp.getSystemService(Context.POWER_SERVICE);
  mPartialWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  if (DBG)   log("- startSequenceInternal: acquiring wake lock");
  mPartialWakeLock.acquire(WAKE_LOCK_TIMEOUT);
  powerOnRadio();
  startRetryTimer();
  mApp.inCallUiState.setProgressIndication(ProgressIndicationType.TURNING_ON_RADIO);
}
 

Example 72

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/fragments/.

Source file: DensityChanger.java

  31 
vote

@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,Preference preference){
  if (preference == mReboot) {
    PowerManager pm=(PowerManager)getActivity().getSystemService(Context.POWER_SERVICE);
    pm.reboot("Resetting density");
    return true;
  }
 else   if (preference == mClearMarketData) {
    new ClearMarketDataTask().execute("");
    return true;
  }
 else   if (preference == mOpenMarket) {
    Intent openMarket=new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ComponentName activityName=openMarket.resolveActivity(getActivity().getPackageManager());
    if (activityName != null) {
      mContext.startActivity(openMarket);
    }
 else {
      preference.setSummary(getResources().getString(R.string.open_market_summary_could_not_open));
    }
    return true;
  }
  return super.onPreferenceTreeClick(preferenceScreen,preference);
}
 

Example 73

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: Controller.java

  31 
vote

@Override public void onPause(){
  if (mUi.isCustomViewShowing()) {
    hideCustomView();
  }
  if (mActivityPaused) {
    Log.e(LOGTAG,"BrowserActivity is already paused.");
    return;
  }
  mActivityPaused=true;
  Tab tab=mTabControl.getCurrentTab();
  if (tab != null) {
    tab.pause();
    if (!pauseWebViewTimers(tab)) {
      if (mWakeLock == null) {
        PowerManager pm=(PowerManager)mActivity.getSystemService(Context.POWER_SERVICE);
        mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"Browser");
      }
      mWakeLock.acquire();
      mHandler.sendMessageDelayed(mHandler.obtainMessage(RELEASE_WAKELOCK),WAKELOCK_TIMEOUT);
    }
  }
  mUi.onPause();
  mNetworkHandler.onPause();
  WebView.disablePlatformNotifications();
  NfcHandler.unregister(mActivity);
  if (sThumbnailBitmap != null) {
    sThumbnailBitmap.recycle();
    sThumbnailBitmap=null;
  }
}
 

Example 74

From project platform_packages_apps_music, under directory /src/com/android/music/.

Source file: MediaPlaybackService.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  ComponentName rec=new ComponentName(getPackageName(),MediaButtonIntentReceiver.class.getName());
  mAudioManager.registerMediaButtonEventReceiver(rec);
  mPreferences=getSharedPreferences("Music",MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);
  mCardId=MusicUtils.getCardId(this);
  registerExternalStorageListener();
  mPlayer=new MultiPlayer();
  mPlayer.setHandler(mMediaplayerHandler);
  reloadQueue();
  notifyChange(QUEUE_CHANGED);
  notifyChange(META_CHANGED);
  IntentFilter commandFilter=new IntentFilter();
  commandFilter.addAction(SERVICECMD);
  commandFilter.addAction(TOGGLEPAUSE_ACTION);
  commandFilter.addAction(PAUSE_ACTION);
  commandFilter.addAction(NEXT_ACTION);
  commandFilter.addAction(PREVIOUS_ACTION);
  registerReceiver(mIntentReceiver,commandFilter);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  mWakeLock.setReferenceCounted(false);
  Message msg=mDelayedStopHandler.obtainMessage();
  mDelayedStopHandler.sendMessageDelayed(msg,IDLE_DELAY);
}
 

Example 75

From project Sketchy-Truck, under directory /andengine/src/org/anddev/andengine/ui/activity/.

Source file: BaseGameActivity.java

  31 
vote

private void acquireWakeLock(final WakeLockOptions pWakeLockOptions){
  if (pWakeLockOptions == WakeLockOptions.SCREEN_ON) {
    ActivityUtils.keepScreenOn(this);
  }
 else {
    final PowerManager pm=(PowerManager)this.getSystemService(Context.POWER_SERVICE);
    this.mWakeLock=pm.newWakeLock(pWakeLockOptions.getFlag() | PowerManager.ON_AFTER_RELEASE,"AndEngine");
    try {
      this.mWakeLock.acquire();
    }
 catch (    final SecurityException e) {
      Debug.e("You have to add\n\t<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>\nto your AndroidManifest.xml !",e);
    }
  }
}
 

Example 76

From project sms-backup-plus, under directory /src/com/zegoggles/smssync/.

Source file: ServiceBase.java

  31 
vote

/** 
 * Acquire locks
 * @param background if service is running in background (no UI)
 * @throws com.zegoggles.smssync.ServiceBase.ConnectivityErrorException when unable to connect
 */
protected void acquireLocks(boolean background) throws ConnectivityErrorException {
  if (sWakeLock == null) {
    PowerManager pMgr=(PowerManager)getSystemService(POWER_SERVICE);
    sWakeLock=pMgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  }
  sWakeLock.acquire();
  WifiManager wMgr=(WifiManager)getSystemService(WIFI_SERVICE);
  if (wMgr.isWifiEnabled() && getConnectivityManager().getNetworkInfo(ConnectivityManager.TYPE_WIFI) != null && getConnectivityManager().getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) {
    if (sWifiLock == null) {
      sWifiLock=wMgr.createWifiLock(TAG);
    }
    sWifiLock.acquire();
  }
 else   if (background && PrefStore.isWifiOnly(this)) {
    throw new ConnectivityErrorException(getString(R.string.error_wifi_only_no_connection));
  }
  NetworkInfo active=getConnectivityManager().getActiveNetworkInfo();
  if (active == null || !active.isConnectedOrConnecting()) {
    throw new ConnectivityErrorException(getString(R.string.error_no_connection));
  }
}
 

Example 77

From project subsonic, under directory /subsonic-android/src/github/daneren2005/dsub/service/.

Source file: DownloadServiceImpl.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setWakeMode(this,PowerManager.PARTIAL_WAKE_LOCK);
  mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener(){
    @Override public boolean onError(    MediaPlayer mediaPlayer,    int what,    int more){
      handleError(new Exception("MediaPlayer error: " + what + " ("+ more+ ")"));
      return false;
    }
  }
);
  Util.requestAudioFocus(this);
  Util.registerMediaButtonEventReceiver(this);
  if (mRemoteControl == null) {
    mRemoteControl=RemoteControlClientHelper.createInstance();
    ComponentName mediaButtonReceiverComponent=new ComponentName(getPackageName(),MediaButtonIntentReceiver.class.getName());
    mRemoteControl.register(this,mediaButtonReceiverComponent);
  }
  if (equalizerAvailable) {
    equalizerController=new EqualizerController(this,mediaPlayer);
    if (!equalizerController.isAvailable()) {
      equalizerController=null;
    }
 else {
      equalizerController.loadSettings();
    }
  }
  if (visualizerAvailable) {
    visualizerController=new VisualizerController(this,mediaPlayer);
    if (!visualizerController.isAvailable()) {
      visualizerController=null;
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  wakeLock.setReferenceCounted(false);
  instance=this;
  lifecycleSupport.onCreate();
}
 

Example 78

From project Subsonic-Android, under directory /src/net/sourceforge/subsonic/androidapp/service/.

Source file: DownloadServiceImpl.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setWakeMode(this,PowerManager.PARTIAL_WAKE_LOCK);
  mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener(){
    @Override public boolean onError(    MediaPlayer mediaPlayer,    int what,    int more){
      handleError(new Exception("MediaPlayer error: " + what + " ("+ more+ ")"));
      return false;
    }
  }
);
  if (equalizerAvailable) {
    equalizerController=new EqualizerController(this,mediaPlayer);
    if (!equalizerController.isAvailable()) {
      equalizerController=null;
    }
 else {
      equalizerController.loadSettings();
    }
  }
  if (visualizerAvailable) {
    visualizerController=new VisualizerController(this,mediaPlayer);
    if (!visualizerController.isAvailable()) {
      visualizerController=null;
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  wakeLock.setReferenceCounted(false);
  instance=this;
  lifecycleSupport.onCreate();
}
 

Example 79

From project subsonic_1, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/.

Source file: DownloadServiceImpl.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setWakeMode(this,PowerManager.PARTIAL_WAKE_LOCK);
  mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener(){
    @Override public boolean onError(    MediaPlayer mediaPlayer,    int what,    int more){
      handleError(new Exception("MediaPlayer error: " + what + " ("+ more+ ")"));
      return false;
    }
  }
);
  if (equalizerAvailable) {
    equalizerController=new EqualizerController(this,mediaPlayer);
    if (!equalizerController.isAvailable()) {
      equalizerController=null;
    }
 else {
      equalizerController.loadSettings();
    }
  }
  if (visualizerAvailable) {
    visualizerController=new VisualizerController(this,mediaPlayer);
    if (!visualizerController.isAvailable()) {
      visualizerController=null;
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  wakeLock.setReferenceCounted(false);
  instance=this;
  lifecycleSupport.onCreate();
}
 

Example 80

From project subsonic_2, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/.

Source file: DownloadServiceImpl.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setWakeMode(this,PowerManager.PARTIAL_WAKE_LOCK);
  mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener(){
    @Override public boolean onError(    MediaPlayer mediaPlayer,    int what,    int more){
      handleError(new Exception("MediaPlayer error: " + what + " ("+ more+ ")"));
      return false;
    }
  }
);
  if (equalizerAvailable) {
    equalizerController=new EqualizerController(this,mediaPlayer);
    if (!equalizerController.isAvailable()) {
      equalizerController=null;
    }
 else {
      equalizerController.loadSettings();
    }
  }
  if (visualizerAvailable) {
    visualizerController=new VisualizerController(this,mediaPlayer);
    if (!visualizerController.isAvailable()) {
      visualizerController=null;
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  wakeLock.setReferenceCounted(false);
  instance=this;
  lifecycleSupport.onCreate();
}
 

Example 81

From project Supersonic, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/.

Source file: DownloadServiceImpl.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mediaPlayer=new MediaPlayer();
  mediaPlayer.setWakeMode(this,PowerManager.PARTIAL_WAKE_LOCK);
  mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener(){
    @Override public boolean onError(    MediaPlayer mediaPlayer,    int what,    int more){
      handleError(new Exception("MediaPlayer error: " + what + " ("+ more+ ")"));
      return false;
    }
  }
);
  if (equalizerAvailable) {
    equalizerController=new EqualizerController(this,mediaPlayer);
    if (!equalizerController.isAvailable()) {
      equalizerController=null;
    }
 else {
      equalizerController.loadSettings();
    }
  }
  if (visualizerAvailable) {
    visualizerController=new VisualizerController(this,mediaPlayer);
    if (!visualizerController.isAvailable()) {
      visualizerController=null;
    }
  }
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  wakeLock.setReferenceCounted(false);
  audioFocusListener=new AudioFocusListener(this);
  audioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  instance=this;
  lifecycleSupport.onCreate();
}
 

Example 82

From project travellog, under directory /src/de/ub0r/android/travelLog/data/.

Source file: LocationChecker.java

  31 
vote

@Override public void onReceive(final Context context,final Intent intent){
  Log.i(TAG,"onReceive(" + intent + ")");
  final PowerManager pm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  final PowerManager.WakeLock wakelock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
  wakelock.acquire();
  Log.i(TAG,"got wakelock");
  final String a=intent.getAction();
  Log.d(TAG,"action: " + a);
  if (a != null && a.equals(Intent.ACTION_BOOT_COMPLETED)) {
    Preferences.registerLocationChecker(context);
  }
 else {
    checkLocation(context);
    long delay=checkWarning(context);
    if (delay > 0L) {
      schedNext(context,delay);
    }
  }
  wakelock.release();
  Log.i(TAG,"wakelock released");
}
 

Example 83

From project TweakGS2, under directory /src/net/sakuramilk/TweakGS2/MultiBoot/.

Source file: ImageCreatePreferenceActivity.java

  31 
vote

@Override public void onClick(View v){
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"Tgs2ImageCreate");
  mWakeLock.acquire();
  mProgressDialog=new ProgressDialog(this);
  mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
  mProgressDialog.setTitle("???");
  mProgressDialog.setMessage("??????????????????\n?????????????????????????");
  mProgressDialog.show();
  Thread thread=new Thread(new Runnable(){
    @Override public void run(){
      int size=Integer.valueOf(mImageSize) * 1024;
      String path=mRootPath + mDstDir + "/"+ mDstFile;
      SystemCommand.make_ext4_image(path,1024,size);
      mCreateImageFinishHandler.sendEmptyMessage(0);
    }
  }
);
  thread.start();
}
 

Example 84

From project Twook, under directory /src/com/nookdevs/common/.

Source file: nookBaseActivity.java

  31 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  PowerManager power=(PowerManager)getSystemService(POWER_SERVICE);
  screenLock=power.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,"nookactivity" + hashCode());
  screenLock.setReferenceCounted(false);
  readSettings();
  PackageManager manager=getPackageManager();
  PackageInfo info;
  try {
    info=manager.getPackageInfo(getPackageName(),0);
    m_Version=info.versionName;
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
    m_Version="";
  }
  updateTitle(NAME);
}
 

Example 85

From project vlc-android, under directory /vlc-android/src/org/videolan/vlc/android/.

Source file: VideoPlayerActivity.java

  31 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.player);
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,TAG);
  mDecor=(LinearLayout)findViewById(R.id.player_overlay_decor);
  mSpacer=(View)findViewById(R.id.player_overlay_spacer);
  mSpacer.setOnTouchListener(mTouchListener);
  LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  mOverlay=(LinearLayout)inflater.inflate(R.layout.player_overlay,null);
  mTime=(TextView)mOverlay.findViewById(R.id.player_overlay_time);
  mLength=(TextView)mOverlay.findViewById(R.id.player_overlay_length);
  mInfo=(TextView)findViewById(R.id.player_overlay_info);
  mPause=(ImageButton)mOverlay.findViewById(R.id.player_overlay_play);
  mPause.setOnClickListener(mPauseListener);
  mLock=(ImageButton)mOverlay.findViewById(R.id.player_overlay_lock);
  mLock.setOnClickListener(mLockListener);
  mSize=(ImageButton)mOverlay.findViewById(R.id.player_overlay_size);
  mSize.setOnClickListener(mSizeListener);
  mSurface=(SurfaceView)findViewById(R.id.player_surface);
  mSurfaceHolder=mSurface.getHolder();
  mSurfaceHolder.setKeepScreenOn(true);
  mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
  mSurfaceHolder.addCallback(mSurfaceCallback);
  mSeekbar=(SeekBar)mOverlay.findViewById(R.id.player_overlay_seekbar);
  mSeekbar.setOnSeekBarChangeListener(mSeekListener);
  try {
    mLibVLC=LibVLC.getInstance();
  }
 catch (  LibVlcException e) {
    e.printStackTrace();
  }
  EventManager em=EventManager.getIntance();
  em.addHandler(eventHandler);
  this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
  load();
}
 

Example 86

From project websms-api, under directory /src/de/ub0r/android/websms/connector/common/.

Source file: ConnectorService.java

  31 
vote

/** 
 * Register a IO task.
 * @param intent intent holding IO operation
 */
private void register(final Intent intent){
  Log.i(TAG,"register(" + intent.getAction() + ")");
synchronized (this.pendingIOOps) {
    if (this.wakelock == null) {
      final PowerManager pm=(PowerManager)this.getSystemService(Context.POWER_SERVICE);
      this.wakelock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG);
      this.wakelock.acquire();
    }
    final ConnectorCommand c=new ConnectorCommand(intent);
    if (c.getType() == ConnectorCommand.TYPE_SEND) {
      if (this.mNM == null) {
        this.mNM=(NotificationManager)this.getSystemService(NOTIFICATION_SERVICE);
      }
      try {
        final Notification notification=getNotification(this,c);
        this.mNM.notify(NOTIFICATION_PENDING,notification);
      }
 catch (      IllegalArgumentException e) {
        Log.e(TAG,"illegal argument",e);
      }
    }
    Log.d(TAG,"currentIOOps=" + this.pendingIOOps.size());
    this.pendingIOOps.add(intent);
    Log.d(TAG,"currentIOOps=" + this.pendingIOOps.size());
  }
}
 

Example 87

From project yammp, under directory /src/org/yammp/.

Source file: MusicPlaybackService.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mApplication=(YAMMPApplication)getApplication();
  mUtils=mApplication.getMediaUtils();
  mPlaybackIntent=new Intent();
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  mAudioManager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(),MediaButtonIntentReceiver.class.getName()));
  mPrefs=new PreferencesEditor(getApplicationContext());
  mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
  mShakeDetector=new ShakeListener(this);
  mCardId=mUtils.getCardId();
  registerExternalStorageListener();
  registerA2dpServiceListener();
  mPlayer=new MultiPlayer();
  mPlayer.setHandler(mMediaplayerHandler);
  if (mEqualizerSupported) {
    mEqualizer=new EqualizerWrapper(0,getAudioSessionId());
    if (mEqualizer != null) {
      mEqualizer.setEnabled(true);
      reloadEqualizer();
    }
  }
  reloadQueue();
  IntentFilter commandFilter=new IntentFilter();
  commandFilter.addAction(SERVICECMD);
  commandFilter.addAction(TOGGLEPAUSE_ACTION);
  commandFilter.addAction(PAUSE_ACTION);
  commandFilter.addAction(NEXT_ACTION);
  commandFilter.addAction(PREVIOUS_ACTION);
  commandFilter.addAction(CYCLEREPEAT_ACTION);
  commandFilter.addAction(TOGGLESHUFFLE_ACTION);
  commandFilter.addAction(BROADCAST_PLAYSTATUS_REQUEST);
  registerReceiver(mIntentReceiver,commandFilter);
  registerReceiver(mExternalAudioDeviceStatusReceiver,new IntentFilter(Intent.ACTION_HEADSET_PLUG));
  PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mWakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,this.getClass().getName());
  mWakeLock.setReferenceCounted(false);
  Message msg=mDelayedStopHandler.obtainMessage();
  mDelayedStopHandler.sendMessageDelayed(msg,IDLE_DELAY);
}
 

Example 88

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: BluetoothHandsfree.java

  29 
vote

public BluetoothHandsfree(Context context,CallManager cm){
  mCM=cm;
  mContext=context;
  BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
  boolean bluetoothCapable=(adapter != null);
  mHeadset=null;
  mA2dp=new BluetoothA2dp(mContext);
  mA2dpState=BluetoothA2dp.STATE_DISCONNECTED;
  mA2dpDevice=null;
  mA2dpSuspended=false;
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mStartCallWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG + ":StartCall");
  mStartCallWakeLock.setReferenceCounted(false);
  mStartVoiceRecognitionWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG + ":VoiceRecognition");
  mStartVoiceRecognitionWakeLock.setReferenceCounted(false);
  mLocalBrsf=BRSF_AG_THREE_WAY_CALLING | BRSF_AG_EC_NR | BRSF_AG_REJECT_CALL| BRSF_AG_ENHANCED_CALL_STATUS;
  if (sVoiceCommandIntent == null) {
    sVoiceCommandIntent=new Intent(Intent.ACTION_VOICE_COMMAND);
    sVoiceCommandIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  }
  if (sVoiceCommandStopIntent == null) {
    sVoiceCommandStopIntent=new Intent(ACTION_VOICE_COMMAND_STOP);
  }
  if (mContext.getPackageManager().resolveActivity(sVoiceCommandIntent,0) != null && BluetoothHeadset.isBluetoothVoiceDialingEnabled(mContext)) {
    mLocalBrsf|=BRSF_AG_VOICE_RECOG;
  }
  mBluetoothPhoneState=new BluetoothPhoneState();
  mUserWantsAudio=true;
  mPhonebook=new BluetoothAtPhonebook(mContext,this);
  mAudioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  cdmaSetSecondCallState(false);
  if (bluetoothCapable) {
    resetAtState();
  }
}
 

Example 89

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: DeleteZone.java

  29 
vote

public DeleteZone(Context context,AttributeSet attributeset){
  super(context,attributeset);
  mIconHoverColorFilter=new PorterDuffColorFilter(0x9fff0000,android.graphics.PorterDuff.Mode.SRC_ATOP);
  TypedArray typedarray=context.obtainStyledAttributes(attributeset,R.styleable.DeleteZone);
  mApplyIconHoverColorFilter=typedarray.getBoolean(1,false);
  mDrawDeleteZoneBg=typedarray.getBoolean(2,false);
  mInOutAnimationDuration=typedarray.getInt(4,200);
  mInOutAnimationTranslationRatio=typedarray.getFloat(3,1.0F);
  pm=(PowerManager)context.getSystemService("power");
  typedarray.recycle();
  init();
}
 

Example 90

From project btmidi, under directory /BluetoothMidiPlayer/src/com/noisepages/nettoyeur/midi/player/.

Source file: BluetoothMidiPlayerService.java

  29 
vote

@Override public void onDeviceConnected(BluetoothDevice device){
  wakeLock=((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,TAG);
  wakeLock.acquire();
  if (receiver != null) {
    receiver.onDeviceConnected(device);
  }
}
 

Example 91

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: SystemLib.java

  29 
vote

public SystemLib(Context context){
  mContext=context;
  mTelephonyManager=(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
  mKeyguardManager=(KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE);
  mBatteryState=new BatteryState(mContext);
  mAudioManager=(AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
  mPowerManager=(PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
  mWifiManager=(WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
  mPackageManager=mContext.getPackageManager();
  mIntentFilter=new IntentFilter();
  mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  mWakeLock=mPowerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK,"Test Acquired!");
  mActivityManager=(ActivityManager)mContext.getSystemService(Context.ACTIVITY_SERVICE);
}
 

Example 92

From project droidkit, under directory /src/org/droidkit/util/tricks/.

Source file: AsyncTricks.java

  29 
vote

protected static synchronized void getWakeLock(String id){
  if (appContext == null)   return;
  if (powerManager == null) {
    powerManager=(PowerManager)appContext.getSystemService(Context.POWER_SERVICE);
  }
  if (activeWakeLock == null) {
    activeWakeLock=powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"AsyncTricks");
    activeWakeLock.acquire();
    if (AsyncTricks.verboseDebug)     Log.d(TAG,"++++ Acquired wakelock: " + id);
  }
}
 

Example 93

From project FBReaderJ, under directory /src/org/geometerplus/zlibrary/ui/android/library/.

Source file: ZLAndroidActivity.java

  29 
vote

public final void createWakeLock(){
  if (myWakeLockToCreate) {
synchronized (this) {
      if (myWakeLockToCreate) {
        myWakeLockToCreate=false;
        myWakeLock=((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,"FBReader");
        myWakeLock.acquire();
      }
    }
  }
  if (myStartTimer) {
    ZLApplication.Instance().startTimer();
    myStartTimer=false;
  }
}
 

Example 94

From project God-Save-The-Bag, under directory /src/com/estudio/cheke/game/gstb/.

Source file: SoundManager.java

  29 
vote

public static void playSound(int song,boolean loop){
  if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
    stop();
  }
  music=song;
switch (song) {
case 0:
    mMediaPlayer=MediaPlayer.create(mContext,R.raw.pachbel0);
  mMediaPlayer.setLooping(loop);
mMediaPlayer.start();
break;
case 1:
mMediaPlayer=MediaPlayer.create(mContext,R.raw.bach_14);
mMediaPlayer.setLooping(loop);
mMediaPlayer.start();
break;
case 2:
mMediaPlayer=MediaPlayer.create(mContext,R.raw.bach_4);
mMediaPlayer.setLooping(loop);
mMediaPlayer.start();
break;
case 3:
mMediaPlayer=MediaPlayer.create(mContext,R.raw.bach_13p);
mMediaPlayer.setLooping(loop);
mMediaPlayer.start();
break;
case 4:
mMediaPlayer=MediaPlayer.create(mContext,R.raw.pachebel);
mMediaPlayer.setLooping(loop);
mMediaPlayer.start();
break;
}
mMediaPlayer.setWakeMode(mContext,PowerManager.PARTIAL_WAKE_LOCK);
if (mMediaPlayer != null) {
float volumen=100;
mMediaPlayer.setVolume(volumen,volumen);
}
}
 

Example 95

From project k-9, under directory /src/com/fsck/k9/activity/.

Source file: FolderList.java

  29 
vote

/** 
 * This class is responsible for reloading the list of local messages for a given folder, notifying the adapter that the message have been loaded and queueing up a remote update of the folder.
 */
private void checkMail(FolderInfoHolder folder){
  TracingPowerManager pm=TracingPowerManager.getPowerManager(this);
  final TracingWakeLock wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"FolderList checkMail");
  wakeLock.setReferenceCounted(false);
  wakeLock.acquire(K9.WAKE_LOCK_TIMEOUT);
  MessagingListener listener=new MessagingListener(){
    @Override public void synchronizeMailboxFinished(    Account account,    String folder,    int totalMessagesInMailbox,    int numNewMessages){
      if (!account.equals(mAccount)) {
        return;
      }
      wakeLock.release();
    }
    @Override public void synchronizeMailboxFailed(    Account account,    String folder,    String message){
      if (!account.equals(mAccount)) {
        return;
      }
      wakeLock.release();
    }
  }
;
  MessagingController.getInstance(getApplication()).synchronizeMailbox(mAccount,folder.name,listener,null);
  sendMail(mAccount);
}
 

Example 96

From project MWM-for-Android, under directory /src/org/metawatch/manager/.

Source file: MetaWatchService.java

  29 
vote

@Override public void onCreate(){
  super.onCreate();
  context=this;
  createNotification();
  connectionState=ConnectionState.CONNECTING;
  watchState=WatchStates.OFF;
  watchType=WatchType.DIGITAL;
  if (bluetoothAdapter == null)   bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
  powerManger=(PowerManager)getSystemService(Context.POWER_SERVICE);
  wakeLock=powerManger.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MetaWatch");
  audioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  Monitors.start(this,telephonyManager);
  start();
}
 

Example 97

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/.

Source file: BluetoothHandsfree.java

  29 
vote

public BluetoothHandsfree(Context context,CallManager cm){
  mCM=cm;
  mContext=context;
  BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
  boolean bluetoothCapable=(adapter != null);
  mHeadset=null;
  mA2dp=new BluetoothA2dp(mContext);
  mA2dpState=BluetoothA2dp.STATE_DISCONNECTED;
  mA2dpDevice=null;
  mA2dpSuspended=false;
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mStartCallWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG + ":StartCall");
  mStartCallWakeLock.setReferenceCounted(false);
  mStartVoiceRecognitionWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAG + ":VoiceRecognition");
  mStartVoiceRecognitionWakeLock.setReferenceCounted(false);
  mLocalBrsf=BRSF_AG_THREE_WAY_CALLING | BRSF_AG_EC_NR | BRSF_AG_REJECT_CALL| BRSF_AG_ENHANCED_CALL_STATUS;
  if (sVoiceCommandIntent == null) {
    sVoiceCommandIntent=new Intent(Intent.ACTION_VOICE_COMMAND);
    sVoiceCommandIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  }
  if (sVoiceCommandStopIntent == null) {
    sVoiceCommandStopIntent=new Intent(ACTION_VOICE_COMMAND_STOP);
  }
  if (mContext.getPackageManager().resolveActivity(sVoiceCommandIntent,0) != null && BluetoothHeadset.isBluetoothVoiceDialingEnabled(mContext)) {
    mLocalBrsf|=BRSF_AG_VOICE_RECOG;
  }
  mBluetoothPhoneState=new BluetoothPhoneState();
  mUserWantsAudio=true;
  mPhonebook=new BluetoothAtPhonebook(mContext,this);
  mAudioManager=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  cdmaSetSecondCallState(false);
  if (bluetoothCapable) {
    resetAtState();
  }
}
 

Example 98

From project roboguice, under directory /roboguice/src/main/java/roboguice/config/.

Source file: RoboModule.java

  29 
vote

/** 
 * Configure this module to define Android related bindings.<br /> <br /> If you want to provide your own bindings, you should <strong>NOT</strong> override this method, but rather create a  {@link Module} implementationand add it to the configuring modules by overriding {@link roboguice.application.RoboApplication#addApplicationModules(List)}.<br />
 */
@SuppressWarnings("unchecked") @Override protected void configure(){
  bindScope(ContextScoped.class,contextScope);
  bind(ContextScope.class).toInstance(contextScope);
  bind(Context.class).toProvider(throwingContextProvider).in(ContextScoped.class);
  bind(Activity.class).toProvider(ActivityProvider.class);
  bind(AssetManager.class).toProvider(AssetManagerProvider.class);
  bind(SharedPreferences.class).toProvider(SharedPreferencesProvider.class);
  bind(Resources.class).toProvider(ResourcesProvider.class);
  bind(ContentResolver.class).toProvider(ContentResolverProvider.class);
  bind(EventManager.class).toInstance(eventManager);
  for (Class<?> c=application.getClass(); c != null && Application.class.isAssignableFrom(c); c=c.getSuperclass())   bind((Class<Object>)c).toInstance(application);
  bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
  bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
  bind(LayoutInflater.class).toProvider(new SystemServiceProvider<LayoutInflater>(Context.LAYOUT_INFLATER_SERVICE));
  bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
  bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
  bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
  bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
  bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
  bind(SearchManager.class).toProvider(new SystemServiceProvider<SearchManager>(Context.SEARCH_SERVICE));
  bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
  bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
  bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
  bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
  bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
  bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
  bindListener(Matchers.any(),resourceListener);
  bindListener(Matchers.any(),extrasListener);
  bindListener(Matchers.any(),viewListener);
  if (preferenceListener != null)   bindListener(Matchers.any(),preferenceListener);
  if (eventManager.isEnabled())   bindListener(Matchers.any(),new ObservesTypeListener(contextProvider,eventManager));
  requestInjection(eventManager);
  requestStaticInjection(Ln.class);
  requestStaticInjection(RoboThread.class);
  requestStaticInjection(RoboAsyncTask.class);
}
 

Example 99

From project TeclaAccess, under directory /source/src/ca/idi/tekla/.

Source file: TeclaApp.java

  29 
vote

private void init(){
  Log.d(TAG,"TECLA APP STARTING ON " + Build.MODEL + " BY "+ Build.MANUFACTURER);
  persistence=new Persistence(this);
  highlighter=new Highlighter(this);
  mPowerManager=(PowerManager)getSystemService(POWER_SERVICE);
  mWakeLock=mPowerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,TeclaApp.TAG);
  mKeyguardManager=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
  mKeyguardLock=mKeyguardManager.newKeyguardLock(TeclaApp.TAG);
  mAudioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
  mPackageManager=getPackageManager();
  mHandler=new Handler();
  mIMECreated=false;
  persistence.unsetInverseScanningChanged();
  persistence.setScreenOn();
  registerReceiver(mReceiver,new IntentFilter(Intent.ACTION_SCREEN_OFF));
  registerReceiver(mReceiver,new IntentFilter(Intent.ACTION_SCREEN_ON));
}