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


Java Intent.ACTION_SCREEN_ON属性代码示例

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


在下文中一共展示了Intent.ACTION_SCREEN_ON属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: provide

@Override
protected void provide() {
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_USER_PRESENT);

    filter.addAction(Intent.ACTION_SHUTDOWN);
    filter.addAction(Intent.ACTION_BOOT_COMPLETED);
    filter.addAction(Intent.ACTION_BATTERY_LOW);
    filter.addAction(Intent.ACTION_BATTERY_OKAY);
    filter.addAction(Intent.ACTION_POWER_CONNECTED);
    filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);

    mReceiver = new DeviceStateReceiver();
    getContext().registerReceiver(mReceiver, filter);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:17,代码来源:DeviceEventUpdatesProvider.java

示例4: onCreate

@Override
public void onCreate() {
    super.onCreate();

    //media player intents
    IntentFilter mediaPlayerFilter = new IntentFilter();
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PLAY);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PAUSE);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.BACK);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.FORWARD);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.STOP);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_ON);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_OFF);
    registerReceiver(MediaPlayerBroadcast, mediaPlayerFilter);

    //screen on / of guard key unlock flag
    IntentFilter screenIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    screenIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    registerReceiver(MediaPlayerNotificationShow, screenIntentFilter);

}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:23,代码来源:AudioService.java

示例5: 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

示例6: onCreate

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

    initLocationManager();

    /*  DB service before listen the event */
    mDBService = DBService.getInstance(getApplicationContext());
    mULRDao = mDBService.getUIDLocationRelationDao();
    mTagDao = mDBService.getTagDao();
    mRLDao = mDBService.getReaderLocationDao();

    DaemonConfiguration.Init(getApplicationContext());
    mDaemon = DaemonConfiguration.getInstance();

    IntentFilter screenOn = new IntentFilter(Intent.ACTION_SCREEN_ON);
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i(TAG, "screen on");
            requestLocation();
        }
    }, screenOn);
}
 
开发者ID:tjjh89017,项目名称:DoorAccess,代码行数:25,代码来源:LocationService.java

示例7: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    SharedPreferences prefs;
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            context.getApplicationContext().registerReceiver(this, filter);
            prefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (prefs.getBoolean(context.getString(R.string.pref_set_on_boot), false)) {
                setVolume(context);
            }
            break;
        case Intent.ACTION_SCREEN_ON:
            prefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (prefs.getBoolean(context.getString(R.string.pref_set_on_screen_on), false)) {
                setVolume(context);
            }
            break;
    }
}
 
开发者ID:Eun,项目名称:InitialVolume,代码行数:20,代码来源:Service.java

示例8: 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

示例9: onCreate

@Override
public void onCreate(){
    if(DEBUG) Log.i(TAG,"Service Started");
    proximitySensorDetails = new ProximitySensorDetails(this);

    IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(screenStateReceiver, screenStateFilter);

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel notificationChannel = new NotificationChannel(CHANNEL, "BlueBolt Pocket Mode", NotificationManager.IMPORTANCE_UNSPECIFIED);
        notificationManager.createNotificationChannel(notificationChannel);

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, SplashActivity.class), 0);

        Notification.Builder builder = new Notification.Builder(this, CHANNEL);
        builder.setContentTitle(notificationTitle)
                .setContentText(notificationText)
                .setSmallIcon(R.mipmap.ic_launcher_foreground)
                .setContentIntent(pendingIntent)
                .setOngoing(true);

        if(DEBUG) Log.i(TAG,"Notification Created");
        startForeground(1, builder.build());
    }

}
 
开发者ID:ShreyanshLodha,项目名称:BlueBolt-Kernel-Tweaking-app,代码行数:28,代码来源:ProximityService.java

示例10: onCreate

@Override
public void onCreate() {
    super.onCreate();
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("receive_incoming_call"));
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("rejected_incoming_call"));
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("EXTRA_STATE_OFFHOOK"));
    //media player intents
    IntentFilter mediaPlayerFilter = new IntentFilter();
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PLAY);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PAUSE);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.BACK);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.FORWARD);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.STOP);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_ON);
    mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_OFF);
    mediaPlayerFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL);
    registerReceiver(MediaPlayerBroadcast, mediaPlayerFilter);

    //screen on / of guard key unlock flag
    IntentFilter screenIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    screenIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    screenIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    registerReceiver(MediaPlayerNotificationShow, screenIntentFilter);


}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:27,代码来源:AudioService.java

示例11: onCreate

@Override
public void onCreate() {

    //Start listening for the Screen On, Screen Off, and Boot completed actions
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_BOOT_COMPLETED);

    //Set up a receiver to listen for the Intents in this Service
    receiver = new LockScreenReceiver();
    registerReceiver(receiver, filter);
    super.onCreate();
}
 
开发者ID:varunon9,项目名称:FakeLock,代码行数:13,代码来源:LockScreenService.java

示例12: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case Intent.ACTION_BOOT_COMPLETED:
            IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
            context.getApplicationContext().registerReceiver(this, filter);
            setBluetooth(context, R.string.pref_set_on_boot);
            break;
        case Intent.ACTION_SCREEN_ON:
            setBluetooth(context, R.string.pref_set_on_screen_on);
            break;
    }
}
 
开发者ID:Eun,项目名称:StartBluetooth,代码行数:13,代码来源:Service.java

示例13: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_activity);

    if (savedInstanceState == null) {
        Fragment preferenceFragment = new BluetoothFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.pref_container, preferenceFragment);
        ft.commit();
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    registerReceiver(new Service(), filter);
}
 
开发者ID:Eun,项目名称:StartBluetooth,代码行数:15,代码来源:SettingsActivity.java

示例14: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_activity);

    if (savedInstanceState == null) {
        Fragment preferenceFragment = new VolumeFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.pref_container, preferenceFragment);
        ft.commit();
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    registerReceiver(new Service(), filter);
}
 
开发者ID:Eun,项目名称:InitialVolume,代码行数:15,代码来源:SettingsActivity.java

示例15: doRegister

private void doRegister() {

        if (mContext == null)
            throw new NullPointerException("context is null");
        if (activity == null)
            throw new NullPointerException("target activity must nonnull");
        Log.i("Infoss", "已经注册广播");
        mScreenStateBroadcast = new ScreenStateBroadcast();
        IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
        mIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
        mContext.registerReceiver(mScreenStateBroadcast, mIntentFilter);
    }
 
开发者ID:Justson,项目名称:Pixel-Activity-Keep-Alive,代码行数:12,代码来源:PixelActivityUnion.java


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