本文整理汇总了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));
}
示例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: 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;
}
示例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);
}
}
示例5: onCreate
@Override
public void onCreate() {
super.onCreate();
global = (Global) getApplication();
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
registerReceiver(receiver, filter);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
}
示例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);
}