Example usage for android.content Intent ACTION_SCREEN_ON

List of usage examples for android.content Intent ACTION_SCREEN_ON

Introduction

In this page you can find the example usage for android.content Intent ACTION_SCREEN_ON.

Prototype

String ACTION_SCREEN_ON

To view the source code for android.content Intent ACTION_SCREEN_ON.

Click Source Link

Document

Broadcast Action: Sent when the device wakes up and becomes interactive.

Usage

From source file:com.tfg.sawan.bsecure.beacon.UriBeaconDiscoveryService.java

/**
 * Create the broadcast receiver that will listen
 * for screen on/off events//ww  w . ja v a 2  s. c o  m
 */
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:jp.morihirosoft.twwb.TwwbService.java

private void registerReceivers() {
    if (DEBUG)/*www . j  a va  2  s. co m*/
        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));
    }
}

From source file:com.ultrafunk.network_info.service.NetworkStateService.java

private void mobileDataInit() {
    mobileDataStatusReceiver = new MobileDataStatusReceiver();
    mobileDataStateListener = new MobileDataStateListener(this);
    mobileDataSettingObserver = new MobileDataSettingObserver(this);

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constants.ACTION_SERVICE_STATE_CHANGED);
    intentFilter.addAction(Constants.ACTION_DATA_CONNECTION_CHANGED);
    intentFilter.addAction(Constants.ACTION_DATA_STATE_CHANGED);
    intentFilter.addAction(Constants.ACTION_DATA_USAGE_UPDATE);
    localBroadcastManager.registerReceiver(mobileDataStatusReceiver, intentFilter);

    registerReceiver(mobileDataStatusReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));

    telephonyManager.listen(mobileDataStateListener,
            PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE);
    getContentResolver().registerContentObserver(mobileDataSettingUri, false, mobileDataSettingObserver);
}

From source file:nu.yona.app.utils.AppUtils.java

/**
 * This will register receiver for different events like screen on-off, boot, connectivity etc.
 *
 * @param context the context//from w ww.j  av  a2 s. co  m
 */
public static void registerReceiver(Context context) {
    loge(TAG, "Register Receiver");

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_BOOT_COMPLETED);
    filter.addAction(AppConstant.RESTART_DEVICE);
    filter.addAction(AppConstant.RESTART_VPN);
    filter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);

    context.registerReceiver(receiver, filter);
}

From source file:com.android.screenspeak.SideTapManager.java

public static IntentFilter getFilter() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    return filter;
}

From source file:org.computeforcancer.android.client.Monitor.java

@Override
public void onCreate() {

    Log.d(Logging.TAG, "Monitor onCreate()");

    // populate attributes with XML resource values
    boincWorkingDir = getString(R.string.client_path);
    fileNameClient = getString(R.string.client_name);
    fileNameCLI = getString(R.string.client_cli);
    fileNameCABundle = getString(R.string.client_cabundle);
    fileNameClientConfig = getString(R.string.client_config);
    fileNameGuiAuthentication = getString(R.string.auth_file_name);
    fileNameAllProjectsList = getString(R.string.all_projects_list);
    clientStatusInterval = getResources().getInteger(R.integer.status_update_interval_ms);
    deviceStatusIntervalScreenOff = getResources()
            .getInteger(R.integer.device_status_update_screen_off_every_X_loop);
    clientSocketAddress = getString(R.string.client_socket_address);

    // initialize singleton helper classes and provide application context
    clientStatus = new ClientStatus(this);
    getAppPrefs().readPrefs(this);
    deviceStatus = new DeviceStatus(this, getAppPrefs());
    if (Logging.ERROR)
        Log.d(Logging.TAG, "Monitor onCreate(): singletons initialized");

    // set current screen on/off status
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    screenOn = pm.isScreenOn();/*www  .j av a2s.  c  o m*/

    // initialize DeviceStatus wrapper
    deviceStatus = new DeviceStatus(getApplicationContext(), getAppPrefs());

    // register screen on/off receiver
    IntentFilter onFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    IntentFilter offFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    registerReceiver(screenOnOffReceiver, onFilter);
    registerReceiver(screenOnOffReceiver, offFilter);
}

From source file:com.android.talkback.SideTapManager.java

@Override
public void onReceive(Context context, Intent intent) {
    if (!TalkBackService.isServiceActive()) {
        return;//from ww w .  ja va 2 s .  c o  m
    }

    String action = intent.getAction();
    if (action.equals(Intent.ACTION_SCREEN_ON)) {
        onReloadPreferences();
    }
    if (action.equals(Intent.ACTION_SCREEN_OFF)) {
        mIntegratedTapDetector.stop();
    }
}

From source file:com.android.screenspeak.SideTapManager.java

@Override
public void onReceive(Context context, Intent intent) {
    if (!ScreenSpeakService.isServiceActive()) {
        return;/*  w  w w . j  av a2  s  .c om*/
    }

    String action = intent.getAction();
    if (action.equals(Intent.ACTION_SCREEN_ON)) {
        onReloadPreferences();
    }
    if (action.equals(Intent.ACTION_SCREEN_OFF)) {
        mIntegratedTapDetector.stop();
    }
}

From source file:com.ultrafunk.network_info.service.NetworkStateService.java

private void wifiInit() {
    wifiStatusReceiver = new WifiStatusReceiver();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constants.ACTION_WIFI_SCANNING);
    intentFilter.addAction(Constants.ACTION_WIFI_LINK_SPEED);
    localBroadcastManager.registerReceiver(wifiStatusReceiver, intentFilter);

    registerReceiver(wifiStatusReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
}

From source file:com.cleanwiz.applock.service.LockService.java

public void registerApplicationReceiver() {
    IntentFilter packageIntentFilter = new IntentFilter();
    IntentFilter eventIntentFilter = new IntentFilter();
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    eventIntentFilter.addAction(Intent.ACTION_TIME_TICK);
    eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageIntentFilter.addDataScheme("package");
    getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter);
    getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter);
    IntentFilter filter = new IntentFilter();
    filter.addAction(LOCK_SERVICE_LASTTIME);
    filter.addAction(LOCK_SERVICE_LEAVEAMENT);
    filter.addAction(LOCK_SERVICE_LEAVERTIME);
    filter.addAction(LOCK_SERVICE_LOCKSTATE);

    lastUnlockTimeSeconds = 0;/*  w  w  w  .  j  a  v  a2 s. co  m*/
    allowedLeaveAment = application.getAllowedLeaveAment();
    leaverTime = application.getLeaverTime();
    lockState = application.getAppLockState();
    registerReceiver(new ServiceReceiver(), filter);
}