本文整理汇总了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));
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}