List of usage examples for android.os PowerManager SCREEN_DIM_WAKE_LOCK
int SCREEN_DIM_WAKE_LOCK
To view the source code for android.os PowerManager SCREEN_DIM_WAKE_LOCK.
Click Source Link
From source file:Main.java
public static void acquireWakeLock(Context context) { if (wakeLock == null) { PowerManager powerManager = (PowerManager) (context.getSystemService(Context.POWER_SERVICE)); wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); wakeLock.acquire();//from ww w. j a va 2 s. c o m } }
From source file:Main.java
public static void toggleWalkLook(Context context, boolean tag) { PowerManager powerManager = (PowerManager) context.getSystemService(Service.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Lock"); wakeLock.setReferenceCounted(false); if (tag)//from w ww . j a v a2s . c o m wakeLock.acquire(); else wakeLock.release(); }
From source file:uk.co.workingedge.phonegap.plugin.PowerManagement.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Log.d(LOG_TAG, "Plugin execute called - " + this.toString()); Log.d(LOG_TAG, "Action is " + action); try {//from w w w . j a v a 2s . co m if (action.equals("acquire")) { String type = args.optString(0); if (type.equals("dim")) { Log.d(LOG_TAG, "Type: dim wakelock"); this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK); } else if (type.equals("bright")) { Log.d(LOG_TAG, "Type: bright wakelock"); this.acquire(PowerManager.SCREEN_BRIGHT_WAKE_LOCK); } else if (type.equals("partial")) { Log.d(LOG_TAG, "Type: partial wakelock"); this.acquire(PowerManager.PARTIAL_WAKE_LOCK); } else { Log.d(LOG_TAG, "Type: full wakelock"); this.acquire(PowerManager.FULL_WAKE_LOCK); } } else if (action.equals("release")) { this.release(); } } catch (Exception e) { return false; } callbackContext.success(); return true; }
From source file:org.apache.cordova.powermanagement.PowerManagement.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { PluginResult result = null;//from w w w. j a v a 2s .c o m Log.d("PowerManagementPlugin", "Plugin execute called - " + this.toString()); Log.d("PowerManagementPlugin", "Action is " + action); try { if (action.equals("acquire")) { if (args.length() > 0 && args.getBoolean(0)) { Log.d("PowerManagementPlugin", "Only dim lock"); result = this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK); } else { result = this.acquire(PowerManager.FULL_WAKE_LOCK); } } else if (action.equals("release")) { result = this.release(); } else if (action.equals("setReleaseOnPause")) { try { this.releaseOnPause = args.getBoolean(0); result = new PluginResult(PluginResult.Status.OK); } catch (Exception e) { result = new PluginResult(PluginResult.Status.ERROR, "Could not set releaseOnPause"); } } } catch (JSONException e) { result = new PluginResult(Status.JSON_EXCEPTION, e.getMessage()); } callbackContext.sendPluginResult(result); return true; }
From source file:se.hockersten.timed.vibration.main.CompetitionTab.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "CompetitionTab.onCreateView()"); if (savedInstanceState != null) { competing = savedInstanceState.getBoolean(COMPETING); visible = savedInstanceState.getBoolean(VISIBLE); lastPress = (Calendar) savedInstanceState.getSerializable(LAST_PRESS); }/*w w w .ja v a 2 s . com*/ root = inflater.inflate(R.layout.main_competition, container, false); return root; }
From source file:com.almarsoft.GroundhogReader.lib.MessagePosterLib.java
public MessagePosterLib(String currentGroup, String groups, String body, String subject, String references, String prevMsgId, Context context) { mCurrentGroup = currentGroup;// ww w . j a v a 2 s . com mContext = context; mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); mGroups = groups.trim(); mBody = body; mSubject = subject.trim(); mPostCharset = mPrefs.getString("postCharset", "ISO8859_15"); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "GroundhogSending"); // Reply to non-first post in a thread if (references != null && references.length() > 0) mReferences = references.trim(); else mReferences = null; // Reply to a thread if (prevMsgId != null && prevMsgId.length() > 0) mPrevMsgId = prevMsgId.trim(); else mPrevMsgId = null; // Message starting new thread // Reply to the first post in thread if (mReferences == null && mPrevMsgId != null) { mReferences = mPrevMsgId; } }
From source file:org.elliotglaysher.lifecounter.LifeCounter.java
/** Called when the activity is first created. */ @Override//from w w w . j ava 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); setupLayouts(); if (savedInstanceState != null) { restoreModelsFromBundle(savedInstanceState); } // Prevent the screen from totally going to sleep... final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); newGame(); }
From source file:com.github.sryze.wirebug.DebugStatusService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "Service is created"); preferences = PreferenceManager.getDefaultSharedPreferences(this); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); }
From source file:org.apache.cordova.plugin.PowerManagement.java
/** * Called by the cordova framework to handle a call to this plugin * @param action currently supported are 'acquire' and 'release' * @param data In case of action 'acquire' this may contain a parameter set to 'true' to indicate only a dim wake-lock *///from ww w. j av a2s. c o m @Override public PluginResult execute(String action, JSONArray data, String callbackId) { PluginResult result = null; Log.d("PowerManagementPlugin", "Plugin execute called - " + this.toString()); Log.d("PowerManagementPlugin", "Action is " + action); try { if (action.equals("acquire")) { if (data.length() > 0 && data.getBoolean(0)) { Log.d("PowerManagementPlugin", "Only dim lock"); result = this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK); } else { result = this.acquire(PowerManager.FULL_WAKE_LOCK); } } else if (action.equals("release")) { result = this.release(); } } catch (JSONException e) { result = new PluginResult(Status.JSON_EXCEPTION, e.getMessage()); } Log.d("PowerManagementPlugin", "Result is " + result.toString()); return result; }
From source file:net.olejon.spotcommander.AddComputerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Power manager final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "wakeLock"); // Allow landscape? if (!mTools.allowLandscape()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Layout// w w w . jav a 2 s . com setContentView(R.layout.activity_add_computer); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.add_computer_toolbar); toolbar.setTitleTextColor(ContextCompat.getColor(mContext, R.color.white)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mAddComputerNameInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_name_layout); mAddComputerUriInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_uri_layout); mAddComputerNameInputLayout.setHintAnimationEnabled(true); mAddComputerUriInputLayout.setHintAnimationEnabled(true); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.add_computer_progressbar); // Information final TextView textView = (TextView) findViewById(R.id.add_computer_information); textView.setMovementMethod(LinkMovementMethod.getInstance()); // Scan dialog new MaterialDialog.Builder(mContext).title(R.string.add_computer_scan_dialog_title) .content(getString(R.string.add_computer_scan_dialog_message)) .positiveText(R.string.add_computer_scan_dialog_positive_button) .negativeText(R.string.add_computer_scan_dialog_negative_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { scanNetwork(); } }).contentColorRes(R.color.black).negativeColorRes(R.color.black).show(); }