List of usage examples for android.content Intent ACTION_SCREEN_OFF
String ACTION_SCREEN_OFF
To view the source code for android.content Intent ACTION_SCREEN_OFF.
Click Source Link
From source file:com.tmall.wireless.tangram3.view.BannerView.java
private void init() { mUltraViewPager = new BannerViewPager(getContext()); mUltraViewPager.setId(R.id.TANGRAM_BANNER_ID); mIndicator = new BannerIndicator(getContext()); addView(mUltraViewPager);/*from w w w . j ava 2 s. com*/ addView(mIndicator); mIndicator.setPadding(mIndicatorGap, 0, 0, 0); mScreenBroadcastReceiver = new ScreenBroadcastReceiver(this); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); }
From source file:org.zywx.wbpalmstar.platform.push.mqttpush.PushGetData.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); if (myBroadcastReceiver == null) { myBroadcastReceiver = new BroadcastReceiver() { @Override// w w w . j a v a2 s .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 (!isNotify && aActiveInfo != null && aActiveInfo.isConnectedOrConnecting()) { init(); isNotify = true; } else { isNotify = false; stop(false); } } else { isNotify = false; stop(false); } } } }; } mCtx.registerReceiver(myBroadcastReceiver, filter); }
From source file:org.yammp.fragment.LyricsFragment.java
@Override public void onStart() { super.onStart(); try {/*from ww w .j a va 2 s .co m*/ float mWindowAnimation = Settings.System.getFloat(getActivity().getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE); mLyricsScrollView.setSmoothScrollingEnabled(mWindowAnimation > 0.0); } catch (SettingNotFoundException e) { e.printStackTrace(); } IntentFilter screenstatusfilter = new IntentFilter(); screenstatusfilter.addAction(Intent.ACTION_SCREEN_ON); screenstatusfilter.addAction(Intent.ACTION_SCREEN_OFF); getActivity().registerReceiver(mScreenTimeoutListener, screenstatusfilter); }
From source file:com.linkbubble.MainService.java
@Override public void onCreate() { mDestroyAllActivities = true;// w ww .ja va2 s. co m mRestoreComplete = false; setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark : R.style.MainServiceThemeLight); super.onCreate(); Fabric.with(this, new Crashlytics()); CrashTracking.log("MainService.onCreate()"); showDefaultNotification(); Config.init(this); Settings.get().onOrientationChange(); try { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } catch (RuntimeException exc) { CrashTracking.logHandledException(exc); } MainApplication.mDestroyActivitySharedLock = new Object(); MainApplication.mActivityDestroyed = false; MainController.create(this, new MainController.EventHandler() { @Override public void onDestroy() { Settings.get().saveBubbleRestingPoint(); stopSelf(); CrashTracking.log("MainService.onCreate(): onDestroy()"); } }); //Intent i = new Intent(); //i.setData(Uri.parse("https://t.co/uxMl3bWtMP")); //i.setData(Uri.parse("http://t.co/oOyu7GBZMU")); //i.setData(Uri.parse("http://goo.gl/abc57")); //i.setData(Uri.parse("https://bitly.com/QtQET")); //i.setData(Uri.parse("http://www.duckduckgo.com")); //openUrl("https://www.duckduckgo.com"); //openUrl("http://www.duckduckgo.com", true); //openUrl("https://t.co/uxMl3bWtMP", true); IntentFilter filter = new IntentFilter(); filter.addAction(BCAST_CONFIGCHANGED); registerReceiver(mBroadcastReceiver, filter); registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mScreenReceiver, filter); MainApplication.registerForBus(this, this); }
From source file:com.inloc.dr.StepService.java
@Override public void onCreate() { Log.i(TAG, "[SERVICE] onCreate"); super.onCreate(); dtr = new DataRecorder(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); showNotification();//from w ww .j a v a2s . c o m // Load settings mSettings = PreferenceManager.getDefaultSharedPreferences(this); mPedometerSettings = new PedometerSettings(mSettings); mState = getSharedPreferences("state", 0); mUtils = Utils.getInstance(); mUtils.setService(this); acquireWakeLock(); // Start detecting mStepDetector = new StepDetector(); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mTurnDetector = new TurnDetector(); mTurnNotifier = new TurnNotifier(); mTurnNotifier.addListener(mAngleListener); mTurnDetector.addTurnListener(mTurnNotifier); registerDetector(); // Register our receiver for the ACTION_SCREEN_OFF action. This will make our receiver // code be called whenever the phone enters standby mode. IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); registerReceiver(mReceiver, filter); mStepDisplayer = new StepDisplayer(mPedometerSettings, mUtils); mStepDisplayer.setSteps(mSteps = mState.getInt("steps", 0)); mStepDisplayer.addListener(mStepListener); mStepDetector.addStepListener(mStepDisplayer); lSteps = mSteps; mConnManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); File mExternalRoot = android.os.Environment.getExternalStorageDirectory(); mOutputDir = new File(mExternalRoot.getAbsolutePath() + "/datalogs/"); // attempt to make output directory if (!mOutputDir.exists()) { mOutputDir.mkdirs(); } // Used when debugging: // mStepBuzzer = new StepBuzzer(this); // mStepDetector.addStepListener(mStepBuzzer); // Start voice reloadSettings(); // Tell the user we started. Toast.makeText(this, getText(R.string.started), Toast.LENGTH_SHORT).show(); }
From source file:arun.com.chromer.appdetect.AppDetectService.java
private void registerScreenReceiver() { final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); screenStateReceiver = new ScreenStateReceiver(); registerReceiver(screenStateReceiver, filter); }
From source file:com.tfg.sawan.bsecure.beacon.UriBeaconDiscoveryService.java
/** * Create the broadcast receiver that will listen * for screen on/off events/*from w w w .j a v a 2 s . com*/ */ private void initializeScreenStateBroadcastReceiver() { mScreenStateBroadcastReceiver = new ScreenBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mScreenStateBroadcastReceiver, intentFilter); }
From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.flashlight.FlashlightService.java
@Override public void onCreate() { sIsRunning = true;/*from w ww . ja va 2s.co m*/ NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getResources().getString(R.string.persistent_flash_active)); builder.setContentText(getResources().getString(R.string.persistent_flash_active_tap)); builder.setSmallIcon(R.drawable.ic_persistent_flash); builder.setContentIntent( PendingIntent.getBroadcast(this, -1, new Intent(getPackageName() + ".STOP_FLASH"), 0)); startForeground(NOTIFICATION_ID, builder.build()); mContainer = new LinearLayout(getApplicationContext()); LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mContainer.setLayoutParams(lparams); mContainer.setOrientation(LinearLayout.VERTICAL); mTurnOffButton = new ImageButton(getApplicationContext()); mTurnOffButton.setImageResource(R.drawable.ic_persistent_flash); mTurnOffButton.setBackgroundColor(0x80000000); mTurnOffButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopSelf(); } }); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = ConstantHolder.getLockscreenType(); params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; params.x = 0; params.y = 0; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = params.width; params.gravity = Gravity.CENTER; params.format = PixelFormat.TRANSLUCENT; mContainer.addView(mTurnOffButton); String method = TogglesResolver.getFlashlightType(getApplicationContext()); if (method.equals("default")) { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } else if (method.equals("htc")) { mFlashManipulator = new HTCFlashlightManipulator(); } else if (method.equals("nosurfaceview")) { mFlashManipulator = new NoSurfaceViewFlashlightManipulator(); } else { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } mWindowManager.addView(mContainer, params); mHandler = new Handler(); mActor = new Runnable() { @Override public void run() { mFlashManipulator.turnFlashlightOn(); } }; mScreenOffReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); mHandler.postDelayed(mActor, 200); } }; mStopServiceReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); stopSelf(); } }; registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mStopServiceReceiver, new IntentFilter(getPackageName() + ".STOP_FLASH")); }
From source file:cn.changwentao.ad.BannerAdView.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); getContext().registerReceiver(mReceiver, filter, null, mHandler); if (mAutoStart) { // ?/*from w w w . jav a 2 s .co m*/ startFlipping(); } }
From source file:jp.morihirosoft.twwb.TwwbService.java
private void registerReceivers() { if (DEBUG)// ww w . j av a2s. c om Log.d(TAG, "registerReceivers"); if (!mIsRegistered) { mIsRegistered = true; registerReceiver(mReceiverScreenOn, new IntentFilter(Intent.ACTION_SCREEN_ON)); registerReceiver(mReceiverScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF)); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); lbm.registerReceiver(mReceiverRecognition, new IntentFilter(Constants.ACTION_RECOGNITION)); } }