当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_SCREEN_OFF属性代码示例

本文整理汇总了Java中android.content.Intent.ACTION_SCREEN_OFF属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_SCREEN_OFF属性的具体用法?Java Intent.ACTION_SCREEN_OFF怎么用?Java Intent.ACTION_SCREEN_OFF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_SCREEN_OFF属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String event = null;
    String type = null;

    switch(intent.getAction()){
        case Intent.ACTION_SCREEN_OFF:
            event = DeviceEvent.EVENT_SCREEN_OFF;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_SCREEN_ON:
            event = DeviceEvent.EVENT_SCREEN_ON;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_USER_PRESENT:
            event = DeviceEvent.EVENT_SCREEN_USER_PRESENT;
            type = DeviceEvent.TYPE_SCREEN;
            break;

        case Intent.ACTION_BOOT_COMPLETED:
            event = DeviceEvent.EVENT_BOOT_COMPLETED;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_SHUTDOWN:
            event = DeviceEvent.EVENT_BOOT_SHUTDOWN;
            type = DeviceEvent.TYPE_BOOT;
            break;

        case Intent.ACTION_BATTERY_LOW:
            event = DeviceEvent.EVENT_BATTERY_LOW;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_BATTERY_OKAY:
            event = DeviceEvent.EVENT_BATTERY_OKAY;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_CONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_CONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case Intent.ACTION_POWER_DISCONNECTED:
            event = DeviceEvent.EVENT_BATTERY_AC_DISCONNECTED;
            type = DeviceEvent.TYPE_BATTERY;
            break;

        case AudioManager.RINGER_MODE_CHANGED_ACTION:
            AudioManager am = (AudioManager)getContext().getSystemService(Context.AUDIO_SERVICE);
            switch (am.getRingerMode()) {
                case AudioManager.RINGER_MODE_SILENT:
                    event = DeviceEvent.EVENT_RINGER_SILENT;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_VIBRATE:
                    event = DeviceEvent.EVENT_RINGER_VIBRATE;
                    type = DeviceEvent.TYPE_RINGER;
                    break;

                case AudioManager.RINGER_MODE_NORMAL:
                    event = DeviceEvent.EVENT_RINGER_NORMAL;
                    type = DeviceEvent.TYPE_RINGER;
                    break;
            }
        default:
            break;
    }

    if (type != null)
        output(new DeviceEvent(type, event));
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:76,代码来源:DeviceEventUpdatesProvider.java

示例2: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    try {
        String action = intent.getAction();
        if(action == Intent.ACTION_BATTERY_CHANGED){
            handleBattery(intent);
        }else if(action == ConnectivityManager.CONNECTIVITY_ACTION){
            AppModel.getNetworkState();
        }else if(action == Intent.ACTION_SCREEN_ON){
            AppModel.sDevScreenOff = false;
            LogUtils.i("screen on");
        }else if(action == Intent.ACTION_SCREEN_OFF){
            AppModel.sDevScreenOff = true;
            LogUtils.i("screen off");
        }
    }catch (Exception e){
        LogUtils.e("onReceive error ", e);
    }

}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:20,代码来源:XndroidReceiver.java

示例3: handleBraodcast

@Override
protected boolean handleBraodcast(Context context, Intent intent) {
    String action = intent.getAction();
    switch (action) {
        case Intent.ACTION_SCREEN_OFF:
            isScreenOff = true;
            stopSming();
            return true;
        case Intent.ACTION_SCREEN_ON:
            isScreenOff = false;
            return true;
    }
    return false;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:14,代码来源:ScreenCaptureService.java

示例4: onReceive

@Override
public void onReceive(Context context, String action, Intent intent) {
    switch (action){
        case Intent.ACTION_SCREEN_OFF:
            onScreenOff(context);
            break;
        case Intent.ACTION_SCREEN_ON:
            onScreenOn(context);
            break;
        default:
            onReceiveOthers(context, action, intent);
    }
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:13,代码来源:ReceiverHelper.java

示例5: onCreate

@Override
public void onCreate() {
    super.onCreate();
    global = (Global) getApplication();
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    registerReceiver(receiver, filter);
}
 
开发者ID:icaynia,项目名称:pracler,代码行数:7,代码来源:LockScreenService.java

示例6: registerReveicer

public void registerReveicer() {
    registerReceiver(netWorkChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    IntentFilter inf = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    inf.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(scrennReceiver, inf);
    registerReceiver(headSetInReceiver, new IntentFilter("android.intent.action.HEADSET_PLUG"));
    IntentFilter bit = new IntentFilter(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
    // bit.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
    //bit.addAction(BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT);
    registerReceiver(blueConnectStateBroadcastReceiver, bit);
    IntentFilter smsFilter = new IntentFilter(SMS_RECEIVED_ACTION);
    smsFilter.setPriority(2147483647);
    smsFilter.addAction(GSM_SMS_RECEIVED_ACTION);
    registerReceiver(smsReceiver, smsFilter);
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:15,代码来源:AssistantService.java

示例7: onCreate

@Override
public void onCreate() {
    Log.d(TAG, "onCreate()");
    super.onCreate();

    //Register ScreenReceiver to screen on/off broadcasts
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    //filter.addAction(Intent.ACTION_SCREEN_ON);
    BroadcastReceiver mReceiver = new ScreenReceiver();
    registerReceiver(mReceiver, filter);
}
 
开发者ID:abicelis,项目名称:PingWidget,代码行数:11,代码来源:PingWidgetUpdateService.java

示例8: onStartCommand

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_BOOT_COMPLETED);
    receiver = new LockScreenReceiver();
    registerReceiver(receiver, filter);
//    startForeground();
    return START_STICKY;

}
 
开发者ID:Jayant11,项目名称:LockScreen-Oreo,代码行数:11,代码来源:LockScreenService.java

示例9: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (action != null) {
        switch (action) {
            case Intent.ACTION_SCREEN_OFF:
                collapsePanel();
                if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) {
                    context.startActivity(new Intent(context, LockScreenActivity.class));
                }
                break;
        }
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:14,代码来源:MainActivity.java

示例10: onCreate

@Override
public void onCreate() {
    super.onCreate();
    //setting up the broadcast

    am = (AudioManager)(getApplicationContext().getSystemService(Context.AUDIO_SERVICE));
    mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.siren);
    mediaPlayer.setLooping(true);

    sensorManager = (SensorManager)getSystemService(getApplicationContext().SENSOR_SERVICE);
    sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    sensorManager.registerListener(this, sensorAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    mBroadcastReceiver = new SMSBroadcastReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.provider.Telephony.SMS_RECEIVED");
    registerReceiver(mBroadcastReceiver, filter);


    IntentFilter newFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    registerReceiver(mReceiver, newFilter);


    PowerManager manager =
            (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, PhoneLocatorService.class.getName());

    // Create a notification area notification so the user
    // can get back to the PhoneLocator Service and Close It

    final Intent notificationIntent = new Intent(getApplicationContext(),
            NirbhayaActivity.class);
    final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
            notificationIntent, 0);

    final Notification notification = new Notification.Builder(
            getApplicationContext())
            .setSmallIcon(R.drawable.ic_launcher)
            .setOngoing(true).setContentTitle("Nirbhaya")
            .setContentText("Click to Access Nirbhaya Service")
            .setContentIntent(pendingIntent).build();

    // Put this Service in a foreground state, so it won't
    // readily be killed by the system
    startForeground(NOTIFICATION_ID, notification);

    firstTimeAlert = false;
    mLocationSendServiceIntent = new Intent(NirbhayaActivity.getMainApp(), LocationSendService.class);
}
 
开发者ID:sommukhopadhyay,项目名称:nirbhaya,代码行数:50,代码来源:PhoneLocatorService.java


注:本文中的android.content.Intent.ACTION_SCREEN_OFF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。