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:fm.krui.kruifm.StreamActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.stream_layout); // Instantiate class members prefManager = new PreferenceManager(this); favTrackManager = new FavoriteTrackManager(this); stationTag = getIntent().getIntExtra(KEY_STATION_TAG, -1); // Set ActionBar Title ActionBar actionBar = getActionBar(); actionBar.setTitle(getString(R.string.listen_sidebar)); actionBar.setSubtitle(getActivitySubtitle(getIntent())); // FIXME: Move these to PreferenceManager after expanding its scope for cleaner code trackPrefs = this.getSharedPreferences(StreamService.PREFS_NAME, 0); // Instantiate broadcast receiver broadcastReceiver = new BroadcastReceiver() { @Override// www.j a v a 2 s. co m public void onReceive(Context context, Intent intent) { processBroadcastCommand(intent); } }; // Retrieve player state to determine how to build this activity boolean playerState = prefManager.getPlayerState(); // If audio is playing in StreamService, we don't want to rebuffer, and we want to restore the UI state from the cache. if (playerState) { restoreUIState(); } // If audio is NOT playing, buffer and treat this launch like a clean startup. else { // Determine the URL we need to use to stream based on the station tag and quality preferences streamUrl = getStreamUrl(stationTag); Log.v(TAG, "streamUrl is now set to: " + streamUrl); // Perform initial configuration of audio server changeUrl(stationTag); // Begin buffering the audio startAudio((ImageView) this.findViewById(R.id.play_audio_imageview)); } // Build play button listener final ImageView playButton = (ImageView) this.findViewById(R.id.play_audio_imageview); playButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleAudio(playButton); } }); // Build volume seek bar listener // ** DISABLED FOR NOW -- This might be completely thrown out. ** /*final SeekBar volumeSeekBar = (SeekBar)this.findViewById(R.id.volume_seekbar); volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // When seek bar progress is changed, change the audio of the media player appropriately. @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // Send new volume via intent? Will this be slow? } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); */ // Build settings button listener and apply it to settings icon and submit button View.OnClickListener flipListener = new View.OnClickListener() { @Override public void onClick(View v) { // Card flip animation which toggles between stream controls and settings views flipCard(); } }; final ImageView settingsButton = (ImageView) this.findViewById(R.id.stream_settings_imageview); final Button saveSettingsButton = (Button) this.findViewById(R.id.set_stream_settings_button); settingsButton.setOnClickListener(flipListener); saveSettingsButton.setOnClickListener(flipListener); // Build favorite button listener final ImageView favoriteButton = (ImageView) this.findViewById(R.id.stream_favorite_imageview); favoriteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (trackIsFavorite) { favoriteButton.setImageResource(R.drawable.star_unfilled_white); trackIsFavorite = false; removeTrackFromFavorites(); } else { favoriteButton.setImageResource(R.drawable.star_filled_white); trackIsFavorite = true; addTrackToFavorites(); } } }); // Build settings switches final Switch streamQualitySwitch = (Switch) this.findViewById(R.id.stream_quality_switch); final Switch albumArtSwitch = (Switch) this.findViewById(R.id.stream_album_art_switch); // Set initial state of switches albumArtSwitch.setChecked(prefManager.getAlbumArtDownloadPreference()); if (prefManager.getStreamQuality() == prefManager.HIGH_QUALITY) { streamQualitySwitch.setChecked(true); } else { streamQualitySwitch.setChecked(false); } // Assign listeners to switches streamQualitySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setStreamQuality(prefManager.HIGH_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } else { prefManager.setStreamQuality(prefManager.LOW_QUALITY); Log.v(TAG, "Stream quality setting is now: " + prefManager.getStreamQuality()); } changeUrl(stationSpinnerPosition); } }); albumArtSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { prefManager.setAlbumArtDownloadPreference(true); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } else { prefManager.setAlbumArtDownloadPreference(false); Log.v(TAG, "Album Art Download setting is now " + prefManager.getAlbumArtDownloadPreference()); } } }); // ***** Old onCreate function starts here! // Initialize screen lock/wake receiver IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver screenReceiver = new ScreenReceiver(); // Attach it to this activity this.getApplicationContext().registerReceiver(screenReceiver, filter); }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java
private void simulateScreenState(boolean screenOn) { Intent intent = new Intent(screenOn ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF); getService().getRingerModeAndScreenMonitor().onReceive(getService(), intent); }
From source file:org.awesomeapp.messenger.ui.ConversationDetailActivity.java
@Override protected void onResume() { super.onResume(); mConvoView.setSelected(true);// w w w . j a v a 2 s.com IntentFilter regFilter = new IntentFilter(); regFilter.addAction(Intent.ACTION_SCREEN_OFF); regFilter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(receiver, regFilter); if (mConvoView.getOtrSessionStatus() == SessionStatus.ENCRYPTED && (!mConvoView.isOtrSessionVerified())) { Snackbar sb = Snackbar.make(mConvoView.getHistoryView(), R.string.not_verified, Snackbar.LENGTH_LONG); sb.setAction(R.string.ok, new View.OnClickListener() { @Override public void onClick(View v) { mConvoView.showVerifyDialog(); } }); sb.show(); ; } }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); T.UI();// w w w .jav a 2s . c o m createWorkerThread(); mUIHandler = new Handler(); T.setUIThread("RegistrationProcedureActivity.onCreate()"); setTitle(R.string.registration_title); mHttpClient = HTTPUtil.getHttpClient(HTTP_TIMEOUT, HTTP_RETRY_COUNT); final IntentFilter filter = new IntentFilter(MainService.INTENT_BEACON_SERVICE_CONNECTED); filter.addAction(RegistrationWizard2.INTENT_GOT_BEACON_REGIONS); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); registerReceiver(mBroadcastReceiver, filter); startRegistrationService(); // TODO: This has to be improved. // If the app relies on GCM the user should not be able to register. if (CloudConstants.USE_GCM_KICK_CHANNEL) GoogleServicesUtils.checkPlayServices(this); }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home);//from ww w . j av a2 s . c om timerValue = (TextView) findViewById(R.id.timerValue); BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String strAction = intent.getAction(); if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON) || strAction.equals(Intent.ACTION_USER_PRESENT)) { if (isThreadOn) { RedFlashLight(); } } } }; final IntentFilter theFilter = new IntentFilter(); /** System Defined Broadcast */ theFilter.addAction(Intent.ACTION_SCREEN_ON); theFilter.addAction(Intent.ACTION_SCREEN_OFF); theFilter.addAction(Intent.ACTION_USER_PRESENT); getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter); imageView1 = (ImageView) findViewById(R.id.imageView1); Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok")); android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { layoutParams.height = 400; } else { layoutParams.height = 180; } imageView1.setLayoutParams(layoutParams); myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); start_button = (Button) findViewById(R.id.start_recording_button); stop_button = (Button) findViewById(R.id.stop_recording_button); buttonColor = start_button.getBackground(); logArea = (TextView) findViewById(R.id.log_area); logArea.setMovementMethod(new ScrollingMovementMethod()); coolmic = new CoolMic(this, "default"); if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) { if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Log.d("WrapperInit", Wrapper.getInitException().toString()); Toast.makeText(getApplicationContext(), "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT) .show(); } } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Toast.makeText(getApplicationContext(), "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT) .show(); } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) { Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT) .show(); } txtListeners = (TextView) findViewById(R.id.txtListeners); IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE); LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter); }
From source file:org.mariotaku.twidere.service.RefreshService.java
@Override public void onCreate() { super.onCreate(); GeneralComponentHelper.build(this).inject(this); mAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); mPendingRefreshHomeTimelineIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_HOME_TIMELINE), 0); mPendingRefreshMentionsIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_NOTIFICATIONS), 0); mPendingRefreshDirectMessagesIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_DIRECT_MESSAGES), 0); mPendingRefreshTrendsIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_TRENDS), 0); final IntentFilter refreshFilter = new IntentFilter(BROADCAST_NOTIFICATION_DELETED); refreshFilter.addAction(BROADCAST_REFRESH_HOME_TIMELINE); refreshFilter.addAction(BROADCAST_REFRESH_NOTIFICATIONS); refreshFilter.addAction(BROADCAST_REFRESH_DIRECT_MESSAGES); refreshFilter.addAction(BROADCAST_RESCHEDULE_HOME_TIMELINE_REFRESHING); refreshFilter.addAction(BROADCAST_RESCHEDULE_MENTIONS_REFRESHING); refreshFilter.addAction(BROADCAST_RESCHEDULE_DIRECT_MESSAGES_REFRESHING); registerReceiver(mStateReceiver, refreshFilter); final IntentFilter batteryFilter = new IntentFilter(); batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED); batteryFilter.addAction(Intent.ACTION_BATTERY_OKAY); batteryFilter.addAction(Intent.ACTION_BATTERY_LOW); batteryFilter.addAction(Intent.ACTION_POWER_CONNECTED); batteryFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); final IntentFilter screenFilter = new IntentFilter(); screenFilter.addAction(Intent.ACTION_SCREEN_ON); screenFilter.addAction(Intent.ACTION_SCREEN_OFF); screenFilter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mPowerStateReceiver, batteryFilter); registerReceiver(mScreenStateReceiver, screenFilter); PowerStateReceiver.setServiceReceiverStarted(true); if (Utils.hasAutoRefreshAccounts(this)) { startAutoRefresh();//from w ww . j ava2 s. c om } else { stopSelf(); } }
From source file:fm.krui.kruifm.StreamFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize screen lock/wake receiver IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); BroadcastReceiver screenReceiver = new ScreenReceiver(); // Attach it to this activity getActivity().getApplicationContext().registerReceiver(screenReceiver, filter); }
From source file:eu.faircode.netguard.SinkholeService.java
@Override public void onCreate() { super.onCreate(); Log.i(TAG, "Create"); HandlerThread thread = new HandlerThread(getString(R.string.app_name)); thread.start();// ww w . j ava 2 s . c o m mServiceLooper = thread.getLooper(); mServiceHandler = new ServiceHandler(mServiceLooper); // 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); // Listen for added applications IntentFilter ifPackage = new IntentFilter(); ifPackage.addAction(Intent.ACTION_PACKAGE_ADDED); ifPackage.addDataScheme("package"); registerReceiver(packageAddedReceiver, ifPackage); }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleNonScheme(String action) { if (Intent.ACTION_SCREEN_OFF.equals(action)) { onScreenOff();//w ww . j ava2 s . c om } else if (Intent.ACTION_SCREEN_ON.equals(action)) { onScreenOn(); } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { if (!SystemHook.isSupported()) { PreventListUtils.notifyNotSupported(mContext); } else if (!PreventListUtils.getInstance().canLoad(mContext)) { PreventListUtils.notifyNoPrevents(mContext); } } }
From source file:org.zywx.wbpalmstar.platform.push.PushService.java
private void onReceive() { final String CONNECTIVITY_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(CONNECTIVITY_CHANGE_ACTION); registerReceiver(new BroadcastReceiver() { @Override/*w ww.jav a 2s . c o m*/ public void onReceive(Context context, Intent intent) { if ("android.intent.action.SCREEN_OFF".equals(intent.getAction())) { if (isTemporary) { sleepTime = 1000 * 60 * 2; } else { sleepTime = 1000 * 60 * 15; } notifiTimer(); } else if ("android.intent.action.SCREEN_ON".equals(intent.getAction())) { if (isTemporary) { sleepTime = 1000 * 30; } else { sleepTime = 1000 * 60 * 2; } notifiTimer(); } if (TextUtils.equals(intent.getAction(), CONNECTIVITY_CHANGE_ACTION)) { ConnectivityManager mConnMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (mConnMgr != null) { NetworkInfo aActiveInfo = mConnMgr.getActiveNetworkInfo(); // ?? if (aActiveInfo != null && aActiveInfo.isConnectedOrConnecting()) { if (!isSend && aActiveInfo.getType() == ConnectivityManager.TYPE_WIFI) { // udpReg(); // notifiUDPTimer(); isSend = true; } } else { isSend = false; } } else { isSend = false; } } } }, filter); }