當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。