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:de.mangelow.throughput.NotificationService.java
@Override public void onCreate() { super.onCreate(); if (D)/*from w ww. ja v a 2 s .co m*/ Log.d(TAG, "Service started"); context = getApplicationContext(); res = context.getResources(); if (tmanager == null) { tmanager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tmanager.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mBroadcastReceiver, filter); int[] refresh_values = res.getIntArray(R.array.refresh_values); long refresh = (long) refresh_values[MainActivity.loadIntPref(context, MainActivity.REFRESH, MainActivity.REFRESH_DEFAULT)]; modifyNotification(R.drawable.ic_stat_zero, null, "", "", new Intent()); if (handler == null) { handler = new Handler(); handler.postDelayed(mRunnable, refresh); } }
From source file:trumeet.keyguard.utils.MaskWindowUtils.java
private void startTimerThread() { final TextView timer = (TextView) mKeyguardView.findViewById(R.id.text_lock_left); new Thread(new Runnable() { private static final String TAG_TIMER = "Timer"; @Override//from www . ja va 2 s . com public void run() { Log.w(TAG_TIMER, "-> run -> Timer Started"); Log.i(TAG_TIMER, "UsedTime#" + mUsedTime + ";Total#" + mTotalTime); Log.i(TAG_TIMER, "Register Screen On Receiver.."); ReceiverUtil receiverUtil = new ReceiverUtil(mContext, new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) { Log.w(TAG_TIMER, "-> onReceive -> screenOn"); mScreenOn++; Log.i(TAG_TIMER, "screenOn#" + mScreenOn); } } }); receiverUtil.subscribe(new IntentFilter(Intent.ACTION_SCREEN_ON)); if (mUsedTime == mTotalTime) { Log.w(TAG_TIMER, "Time is Up, Resetting"); mUsedTime = 0; } for (; mUsedTime <= mTotalTime; mUsedTime++) { mPrefsUtil.updateUsed(mUsedTime); runOnUiThread(new Runnable() { @Override public void run() { timer.setText(mContext.getString(R.string.text_time_left, Utils.formatSecToStr(BigDecimal.valueOf(mTotalTime - mUsedTime)))); } }); try { Thread.sleep(1000); } catch (Exception ignore) { } } Log.i(TAG_TIMER, "Time is Up"); dismissKeyguardView(); receiverUtil.unsubscribe(); mPrefsUtil.onFinish(mScreenOn); } }).start(); }
From source file:pl.zajecia.cw3.MainService.java
/** * Registers alarm receiver, handling options * (adding intent filters for SCREEN_ON etc). *///w w w . j av a2 s . c o m private void registerAlarmReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(INTENT_ALARM); if (mChangeOnScreenOn) { intentFilter.addAction(Intent.ACTION_SCREEN_ON); } registerReceiver(mAlarmBroadcastReceiver, intentFilter); mAlarmBroadcastReceiverEnabled = true; }
From source file:com.zhengde163.netguard.ActivitySettings.java
@Override protected void onResume() { super.onResume(); // Check if permissions were revoked checkPermissions();/*from w w w . j ava 2 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); // Listen for connectivity updates IntentFilter ifConnectivity = new IntentFilter(); ifConnectivity.addAction(ConnectivityManager.CONNECTIVITY_ACTION); if (Util.hasPhoneStatePermission(this)) { phone_state = true; } }
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 ww .j av a 2 s . c om 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.yammp.fragment.LyricsFragment.java
@Override public void onStart() { super.onStart(); try {//from w w w .jav a 2 s . c o 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: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//from w w w . j a v a 2 s . co 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:com.linkbubble.MainService.java
@Override public void onCreate() { mDestroyAllActivities = true;/* w ww .j a v a 2s . 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: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.farmerbb.secondscreen.service.NotificationService.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// w ww . jav a2s. c o m public void onCreate() { // Load preferences SharedPreferences prefCurrent = U.getPrefCurrent(this); SharedPreferences prefMain = U.getPrefMain(this); // Register broadcast receivers for screen on and user present final IntentFilter filter1 = new IntentFilter(); final IntentFilter filter2 = new IntentFilter(); filter1.addAction(Intent.ACTION_SCREEN_ON); filter1.addAction(Intent.ACTION_DREAMING_STARTED); filter2.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(screenOnReceiver, filter1); registerReceiver(userPresentReceiver, filter2); DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE); manager.registerDisplayListener(listener, null); // Intent to launch MainActivity when notification is clicked Intent mainActivityIntent = new Intent(this, MainActivity.class); PendingIntent mainActivityPendingIntent = PendingIntent.getActivity(this, 0, mainActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Build the notification mBuilder = new NotificationCompat.Builder(this).setContentIntent(mainActivityPendingIntent) .setSmallIcon(R.drawable.ic_action_dock) .setContentTitle(getResources().getString(R.string.notification)) .setContentText( prefCurrent.getString("profile_name", getResources().getString(R.string.action_new))) .setOngoing(true); // Set action buttons setActionButton(prefMain.getString("notification_action_2", "turn-off"), prefCurrent, 0); setActionButton(prefMain.getString("notification_action", "lock-device"), prefCurrent, 1); // Respect setting to hide notification if (prefMain.getBoolean("hide_notification", false)) mBuilder.setPriority(Notification.PRIORITY_MIN); // Set notification color on Lollipop if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setColor(getResources().getColor(R.color.primary_dark)) .setVisibility(Notification.VISIBILITY_PUBLIC); } // Start NotificationService startForeground(1, mBuilder.build()); // Draw system overlay, if needed if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(this) && prefCurrent.getString("rotation_lock_new", "fallback").equals("landscape")) { windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; view = new View(this); windowManager.addView(view, params); } }