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