List of usage examples for android.content Intent ACTION_SCREEN_ON
String ACTION_SCREEN_ON
To view the source code for android.content Intent ACTION_SCREEN_ON.
Click Source Link
From source file:com.androzic.vnspeech.MapFragment.java
@Override public void onResume() { super.onResume(); Log.e(TAG, "onResume()"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity()); onSharedPreferenceChanged(settings, getString(R.string.pref_maprenderinterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapfollowonloc)); onSharedPreferenceChanged(settings, getString(R.string.pref_wakelock)); onSharedPreferenceChanged(settings, getString(R.string.pref_showdistance_int)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidemapinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidesatinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidenavinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdiminterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdimvalue)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdim)); onSharedPreferenceChanged(settings, getString(R.string.pref_unfollowontap)); onSharedPreferenceChanged(settings, getString(R.string.pref_lookahead)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapbest)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapbestinterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapforcezoom)); onSharedPreferenceChanged(settings, getString(R.string.pref_maprotation)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarbg)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarbgcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidemapcross)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapcrosscolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_cursorvector)); onSharedPreferenceChanged(settings, getString(R.string.pref_cursorcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_navigation_proximity)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitspeed)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitelevation)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitangle)); PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this); updateEditStatus();//from www . jav a2 s . c o m updateGPSStatus(); onUpdateNavigationState(); onUpdateNavigationStatus(); application.registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATUS)); application.registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATE)); application.registerReceiver(broadcastReceiver, new IntentFilter(LocationService.BROADCAST_LOCATING_STATUS)); application.registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); application.registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); map.setKeepScreenOn(keepScreenOn); map.setFollowing(following); mapButtonsVisible = settings.getBoolean(getString(R.string.ui_mapbuttons_shown), true); mapButtons.setVisibility(mapButtonsVisible ? View.VISIBLE : View.GONE); updateMapViewArea(); // Start updating UI map.resume(); map.updateMapInfo(); map.updateMapCenter(); map.requestFocus(); updateCallback.post(updateUI); tooltipCallback.postDelayed(showTooltip, TooltipManager.TOOLTIP_DELAY); }
From source file:com.cssweb.android.base.BaseActivity.java
private void listenScreen() { lockreceiver = new BroadcastReceiver() { @Override//from ww w . j a v a 2s . c o m public void onReceive(Context context, Intent intent) { ServiceControl.pauseScreenReceiver(); } }; registerReceiver(lockreceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); homereceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { ServiceControl.resumeScreenReceiver(); } }; registerReceiver(homereceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); }
From source file:com.dudu.aios.ui.activity.MainRecordActivity.java
private void registerScreenReceiver() { mScreenReceiver = new ScreenReceiver(); IntentFilter filter = new IntentFilter(); // ???//w w w. ja v a2 s .c o m filter.addAction(Intent.ACTION_SCREEN_OFF); // ?? filter.addAction(Intent.ACTION_SCREEN_ON); // ?? filter.addAction(Intent.ACTION_USER_PRESENT); // ?????? // example????????? // ????pad?? filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mScreenReceiver, filter); }
From source file:com.google.android.marvin.mytalkback.TalkBackService.java
/** * Suspends TalkBack and Explore by Touch. *//*from w w w . jav a 2 s . c o m*/ private void suspendTalkBack() { if (!isServiceActive()) { LogUtils.log(this, Log.ERROR, "Attempted to suspend TalkBack while already suspended."); return; } mFeedbackController.playAuditory(R.id.sounds_paused_feedback); if (SUPPORTS_TOUCH_PREF) { requestTouchExploration(false); } if (mCursorController != null) { mCursorController.clearCursor(); } final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_RESUME_FEEDBACK); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mSuspendedReceiver, filter, PERMISSION_TALKBACK, null); // Suspending infrastructure sets sIsTalkBackSuspended to true. suspendInfrastructure(); final Intent resumeIntent = new Intent(ACTION_RESUME_FEEDBACK); final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, resumeIntent, 0); final Notification notification = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.notification_title_talkback_suspended)) .setContentText(getString(R.string.notification_message_talkback_suspended)) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.ic_stat_info) .setContentIntent(pendingIntent).setOngoing(true).setWhen(0).build(); startForeground(R.id.notification_suspended, notification); }
From source file:mp.teardrop.PlaybackService.java
@Override public void onCreate() { HandlerThread thread = new HandlerThread("PlaybackService", Process.THREAD_PRIORITY_DEFAULT); thread.start();/*from w ww . ja v a2 s . co m*/ mTimeline = new SongTimeline(this); mTimeline.setCallback(this); int state = loadState(); mPlayCounts = new PlayCountsHelper(this); mMediaPlayer = getNewMediaPlayer(); mBastpUtil = new BastpUtil(); mReadahead = new ReadaheadThread(); mReadahead.start(); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE); SharedPreferences settings = getSettings(this); settings.registerOnSharedPreferenceChangeListener(this); mNotificationMode = Integer.parseInt(settings.getString(PrefKeys.NOTIFICATION_MODE, "1")); mScrobble = settings.getBoolean(PrefKeys.SCROBBLE, false); mIdleTimeout = settings.getBoolean(PrefKeys.USE_IDLE_TIMEOUT, false) ? settings.getInt(PrefKeys.IDLE_TIMEOUT, 3600) : 0; Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_ANDROID, true) ? Song.mCoverLoadMode | Song.COVER_MODE_ANDROID : Song.mCoverLoadMode & ~(Song.COVER_MODE_ANDROID); Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_VANILLA, true) ? Song.mCoverLoadMode | Song.COVER_MODE_VANILLA : Song.mCoverLoadMode & ~(Song.COVER_MODE_VANILLA); Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_SHADOW, true) ? Song.mCoverLoadMode | Song.COVER_MODE_SHADOW : Song.mCoverLoadMode & ~(Song.COVER_MODE_SHADOW); mHeadsetOnly = settings.getBoolean(PrefKeys.HEADSET_ONLY, false); mStockBroadcast = settings.getBoolean(PrefKeys.STOCK_BROADCAST, false); mInvertNotification = settings.getBoolean(PrefKeys.NOTIFICATION_INVERTED_COLOR, false); mNotificationAction = createNotificationAction(settings); mHeadsetPause = getSettings(this).getBoolean(PrefKeys.HEADSET_PAUSE, true); mShakeAction = settings.getBoolean(PrefKeys.ENABLE_SHAKE, false) ? Action.getAction(settings, PrefKeys.SHAKE_ACTION, Action.NextSong) : Action.Nothing; mShakeThreshold = settings.getInt(PrefKeys.SHAKE_THRESHOLD, 80) / 10.0f; mReplayGainTrackEnabled = settings.getBoolean(PrefKeys.ENABLE_TRACK_REPLAYGAIN, false); mReplayGainAlbumEnabled = settings.getBoolean(PrefKeys.ENABLE_ALBUM_REPLAYGAIN, false); mReplayGainBump = settings.getInt(PrefKeys.REPLAYGAIN_BUMP, 75); /* seek bar is 150 -> 75 == middle == 0 */ mReplayGainUntaggedDeBump = settings.getInt(PrefKeys.REPLAYGAIN_UNTAGGED_DEBUMP, 150); /* seek bar is 150 -> == 0 */ mReadaheadEnabled = settings.getBoolean(PrefKeys.ENABLE_READAHEAD, false); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TeardropMusicLock"); mReceiver = new Receiver(); IntentFilter filter = new IntentFilter(); filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mReceiver, filter); getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mObserver); CompatIcs.registerRemote(this, mAudioManager); mLooper = thread.getLooper(); mHandler = new Handler(mLooper, this); initWidgets(); updateState(state); setCurrentSong(0, false); sInstance = this; synchronized (sWait) { sWait.notifyAll(); } mAccelFiltered = 0.0f; mAccelLast = SensorManager.GRAVITY_EARTH; setupSensor(); }
From source file:com.google.android.marvin.screenspeak.ScreenSpeakService.java
/** * Suspends ScreenSpeak and Explore by Touch. *///ww w . j a va 2 s . c om public void suspendScreenSpeak() { if (!isServiceActive()) { if (LogUtils.LOG_LEVEL <= Log.ERROR) { Log.e(LOGTAG, "Attempted to suspend ScreenSpeak while already suspended."); } return; } SharedPreferencesUtils.storeBooleanAsync(mPrefs, getString(R.string.pref_suspended), true); mFeedbackController.playAuditory(R.raw.paused_feedback); if (mSupportsTouchScreen) { requestTouchExploration(false); } if (mCursorController != null) { try { mCursorController.clearCursor(); } catch (SecurityException e) { if (LogUtils.LOG_LEVEL >= Log.ERROR) { Log.e(LOGTAG, "Unable to clear cursor"); } } } final IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_RESUME_FEEDBACK); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mSuspendedReceiver, filter, PERMISSION_SCREENSPEAK, null); // Suspending infrastructure sets sIsScreenSpeakSuspended to true. suspendInfrastructure(); final Intent resumeIntent = new Intent(ACTION_RESUME_FEEDBACK); final PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, resumeIntent, 0); final Notification notification = new NotificationCompat.Builder(this) .setContentTitle(getString(R.string.notification_title_screenspeak_suspended)) .setContentText(getString(R.string.notification_message_screenspeak_suspended)) .setPriority(NotificationCompat.PRIORITY_MAX).setSmallIcon(R.drawable.ic_stat_info) .setContentIntent(pendingIntent).setOngoing(true).setWhen(0).build(); startForeground(R.id.notification_suspended, notification); mSpeechController.speak(getString(R.string.screenspeak_suspended), SpeechController.QUEUE_MODE_UNINTERRUPTIBLE, 0, null); }
From source file:org.musicmod.android.app.MusicPlaybackActivity.java
@Override public void onStart() { super.onStart(); paused = false;/*from w ww .j av a 2s. c o m*/ mToken = MusicUtils.bindToService(this, this); if (mToken == null) { // something went wrong mHandler.sendEmptyMessage(QUIT); } loadPreferences(); if (mBlurBackground) { getWindow().addFlags(LayoutParams.FLAG_BLUR_BEHIND); } else { getWindow().clearFlags(LayoutParams.FLAG_BLUR_BEHIND); } if (mLyricsWakelock) { getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); } try { float mTransitionAnimation = Settings.System.getFloat(this.getContentResolver(), Settings.System.TRANSITION_ANIMATION_SCALE); if (mTransitionAnimation > 0.0) { mShowFadeAnimation = true; } else { mShowFadeAnimation = false; } } catch (SettingNotFoundException e) { e.printStackTrace(); } IntentFilter f = new IntentFilter(); f.addAction(BROADCAST_PLAYSTATE_CHANGED); f.addAction(BROADCAST_META_CHANGED); f.addAction(BROADCAST_FAVORITESTATE_CHANGED); registerReceiver(mStatusListener, new IntentFilter(f)); IntentFilter s = new IntentFilter(); s.addAction(Intent.ACTION_SCREEN_ON); s.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mScreenTimeoutListener, new IntentFilter(s)); long next = refreshNow(); queueNextRefresh(next); }
From source file:org.linphone.LinphoneService.java
public void initFromConf() throws LinphoneConfigException, LinphoneException { // traces// www .ja v a2 s. co m boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false); LinphoneCoreFactory.instance().setDebugMode(lIsDebug); try { // Configure audio codecs enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key); enableDisableAudioCodec("speex", 16000, R.string.pref_codec_speex16_key); enableDisableAudioCodec("speex", 8000, R.string.pref_codec_speex8_key); enableDisableAudioCodec("iLBC", 8000, R.string.pref_codec_ilbc_key); enableDisableAudioCodec("GSM", 8000, R.string.pref_codec_gsm_key); enableDisableAudioCodec("PCMU", 8000, R.string.pref_codec_pcmu_key); enableDisableAudioCodec("PCMA", 8000, R.string.pref_codec_pcma_key); // Configure video codecs for (PayloadType videoCodec : mLinphoneCore.listVideoCodecs()) { enableDisableVideoCodecs(videoCodec); } if (!mPref.getString(getString(R.string.pref_handle_outcall_key), OutgoingCallReceiver.key_on_demand) .equalsIgnoreCase(OutgoingCallReceiver.key_off)) { IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); lFilter.setPriority(0); lFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL); if (mOutgoingCallReceiver == null) { mOutgoingCallReceiver = new OutgoingCallReceiver(); } registerReceiver(mOutgoingCallReceiver, lFilter); } else if (mOutgoingCallReceiver != null) { unregisterReceiver(mOutgoingCallReceiver); mOutgoingCallReceiver = null; } mLinphoneCore.enableEchoCancellation( mPref.getBoolean(getString(R.string.pref_echo_cancellation_key), false)); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } boolean isVideoEnabled = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); mLinphoneCore.enableVideo(isVideoEnabled, isVideoEnabled); // 1 read proxy config from preferences String lUserName = mPref.getString(getString(R.string.pref_username_key), null); lUserName = username; if (lUserName == null || lUserName.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_username)); } String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null); lPasswd = password; if (lPasswd == null || lPasswd.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_passwd)); } String lDomain = mPref.getString(getString(R.string.pref_domain_key), null); lDomain = domain; if (lDomain == null || lDomain.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_domain)); } String lStun = mPref.getString(getString(R.string.pref_stun_server_key), null); // stun server mLinphoneCore.setStunServer(lStun); mLinphoneCore.setFirewallPolicy( (lStun != null && lStun.length() > 0) ? FirewallPolicy.UseStun : FirewallPolicy.NoFirewall); // auth mLinphoneCore.clearAuthInfos(); LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd, null); mLinphoneCore.addAuthInfo(lAuthInfo); // proxy mLinphoneCore.clearProxyConfigs(); String lProxy = mPref.getString(getString(R.string.pref_proxy_key), null); if (lProxy == null || lProxy.length() == 0) { lProxy = "sip:" + lDomain; } if (!lProxy.startsWith("sip:")) { lProxy = "sip:" + lProxy; } // get Default proxy if any LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); String lIdentity = "sip:" + lUserName + "@" + lDomain; try { if (lDefaultProxyConfig == null) { lDefaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(lIdentity, lProxy, null, true); mLinphoneCore.addProxyConfig(lDefaultProxyConfig); mLinphoneCore.setDefaultProxyConfig(lDefaultProxyConfig); } else { lDefaultProxyConfig.edit(); lDefaultProxyConfig.setIdentity(lIdentity); lDefaultProxyConfig.setProxy(lProxy); lDefaultProxyConfig.enableRegister(true); lDefaultProxyConfig.done(); } lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); if (lDefaultProxyConfig != null) { // prefix String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null); if (lPrefix != null) { lDefaultProxyConfig.setDialPrefix(lPrefix); } // escape + lDefaultProxyConfig .setDialEscapePlus(mPref.getBoolean(getString(R.string.pref_escape_plus_key), false)); // outbound proxy if (mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key), false)) { lDefaultProxyConfig.setRoute(lProxy); } else { lDefaultProxyConfig.setRoute(null); } } // init network state ConnectivityManager lConnectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo lInfo = lConnectivityManager.getActiveNetworkInfo(); mLinphoneCore.setNetworkReachable(lInfo != null ? lConnectivityManager.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED : false); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
@Override protected void onResume() { super.onResume(); // Check if permissions were revoked checkPermissions();/* w w w .j a va2s . c o m*/ // Listen for preference changes SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); // Listen for interactive state changes IntentFilter ifInteractive = new IntentFilter(); ifInteractive.addAction(Intent.ACTION_SCREEN_ON); ifInteractive.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(interactiveStateReceiver, ifInteractive); // Listen for connectivity updates IntentFilter ifConnectivity = new IntentFilter(); ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(connectivityChangedReceiver, ifConnectivity); if (Util.hasPhoneStatePermission(this)) { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(phoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE); phone_state = true; } }
From source file:eu.faircode.netguard.ActivitySettings.java
@Override protected void onResume() { super.onResume(); checkPermissions(null);//www . j a va2 s . c o m // Listen for preference changes SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); // Listen for interactive state changes IntentFilter ifInteractive = new IntentFilter(); ifInteractive.addAction(Intent.ACTION_SCREEN_ON); ifInteractive.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(interactiveStateReceiver, ifInteractive); // Listen for connectivity updates IntentFilter ifConnectivity = new IntentFilter(); ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(connectivityChangedReceiver, ifConnectivity); }