List of usage examples for android.content Intent ACTION_USER_PRESENT
String ACTION_USER_PRESENT
To view the source code for android.content Intent ACTION_USER_PRESENT.
Click Source Link
From source file:com.tmall.wireless.tangram3.view.BannerView.java
private void init() { mUltraViewPager = new BannerViewPager(getContext()); mUltraViewPager.setId(R.id.TANGRAM_BANNER_ID); mIndicator = new BannerIndicator(getContext()); addView(mUltraViewPager);//ww w.j ava 2 s.c om addView(mIndicator); mIndicator.setPadding(mIndicatorGap, 0, 0, 0); mScreenBroadcastReceiver = new ScreenBroadcastReceiver(this); filter.addAction(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); }
From source file:com.linkbubble.MainService.java
@Override public void onCreate() { mDestroyAllActivities = true;/*w ww. jav a 2 s .com*/ mRestoreComplete = false; setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark : R.style.MainServiceThemeLight); super.onCreate(); Fabric.with(this, new Crashlytics()); CrashTracking.log("MainService.onCreate()"); showDefaultNotification(); Config.init(this); Settings.get().onOrientationChange(); try { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } catch (RuntimeException exc) { CrashTracking.logHandledException(exc); } MainApplication.mDestroyActivitySharedLock = new Object(); MainApplication.mActivityDestroyed = false; MainController.create(this, new MainController.EventHandler() { @Override public void onDestroy() { Settings.get().saveBubbleRestingPoint(); stopSelf(); CrashTracking.log("MainService.onCreate(): onDestroy()"); } }); //Intent i = new Intent(); //i.setData(Uri.parse("https://t.co/uxMl3bWtMP")); //i.setData(Uri.parse("http://t.co/oOyu7GBZMU")); //i.setData(Uri.parse("http://goo.gl/abc57")); //i.setData(Uri.parse("https://bitly.com/QtQET")); //i.setData(Uri.parse("http://www.duckduckgo.com")); //openUrl("https://www.duckduckgo.com"); //openUrl("http://www.duckduckgo.com", true); //openUrl("https://t.co/uxMl3bWtMP", true); IntentFilter filter = new IntentFilter(); filter.addAction(BCAST_CONFIGCHANGED); registerReceiver(mBroadcastReceiver, filter); registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mScreenReceiver, filter); MainApplication.registerForBus(this, this); }
From source file:com.farmerbb.secondscreen.service.NotificationService.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from ww w.ja v a 2s . com*/ public void onCreate() { // Load preferences SharedPreferences prefCurrent = U.getPrefCurrent(this); SharedPreferences prefMain = U.getPrefMain(this); // Register broadcast receivers for screen on and user present final IntentFilter filter1 = new IntentFilter(); final IntentFilter filter2 = new IntentFilter(); filter1.addAction(Intent.ACTION_SCREEN_ON); filter1.addAction(Intent.ACTION_DREAMING_STARTED); filter2.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(screenOnReceiver, filter1); registerReceiver(userPresentReceiver, filter2); DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE); manager.registerDisplayListener(listener, null); // Intent to launch MainActivity when notification is clicked Intent mainActivityIntent = new Intent(this, MainActivity.class); PendingIntent mainActivityPendingIntent = PendingIntent.getActivity(this, 0, mainActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Build the notification mBuilder = new NotificationCompat.Builder(this).setContentIntent(mainActivityPendingIntent) .setSmallIcon(R.drawable.ic_action_dock) .setContentTitle(getResources().getString(R.string.notification)) .setContentText( prefCurrent.getString("profile_name", getResources().getString(R.string.action_new))) .setOngoing(true); // Set action buttons setActionButton(prefMain.getString("notification_action_2", "turn-off"), prefCurrent, 0); setActionButton(prefMain.getString("notification_action", "lock-device"), prefCurrent, 1); // Respect setting to hide notification if (prefMain.getBoolean("hide_notification", false)) mBuilder.setPriority(Notification.PRIORITY_MIN); // Set notification color on Lollipop if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setColor(getResources().getColor(R.color.primary_dark)) .setVisibility(Notification.VISIBILITY_PUBLIC); } // Start NotificationService startForeground(1, mBuilder.build()); // Draw system overlay, if needed if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(this) && prefCurrent.getString("rotation_lock_new", "fallback").equals("landscape")) { windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; view = new View(this); windowManager.addView(view, params); } }
From source file:cn.changwentao.ad.BannerAdView.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); getContext().registerReceiver(mReceiver, filter, null, mHandler); if (mAutoStart) { // ?/* w w w. jav a 2 s .co m*/ startFlipping(); } }
From source file:com.cleanwiz.applock.service.LockService.java
public void registerApplicationReceiver() { IntentFilter packageIntentFilter = new IntentFilter(); IntentFilter eventIntentFilter = new IntentFilter(); eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF); eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON); eventIntentFilter.addAction(Intent.ACTION_TIME_TICK); eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT); eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageIntentFilter.addDataScheme("package"); getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter); getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter); IntentFilter filter = new IntentFilter(); filter.addAction(LOCK_SERVICE_LASTTIME); filter.addAction(LOCK_SERVICE_LEAVEAMENT); filter.addAction(LOCK_SERVICE_LEAVERTIME); filter.addAction(LOCK_SERVICE_LOCKSTATE); lastUnlockTimeSeconds = 0;/*from w w w .ja v a 2 s . c o m*/ allowedLeaveAment = application.getAllowedLeaveAment(); leaverTime = application.getLeaverTime(); lockState = application.getAppLockState(); registerReceiver(new ServiceReceiver(), filter); }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home);//from www.j ava2s .co m timerValue = (TextView) findViewById(R.id.timerValue); BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String strAction = intent.getAction(); if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON) || strAction.equals(Intent.ACTION_USER_PRESENT)) { if (isThreadOn) { RedFlashLight(); } } } }; final IntentFilter theFilter = new IntentFilter(); /** System Defined Broadcast */ theFilter.addAction(Intent.ACTION_SCREEN_ON); theFilter.addAction(Intent.ACTION_SCREEN_OFF); theFilter.addAction(Intent.ACTION_USER_PRESENT); getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter); imageView1 = (ImageView) findViewById(R.id.imageView1); Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok")); android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { layoutParams.height = 400; } else { layoutParams.height = 180; } imageView1.setLayoutParams(layoutParams); myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); start_button = (Button) findViewById(R.id.start_recording_button); stop_button = (Button) findViewById(R.id.stop_recording_button); buttonColor = start_button.getBackground(); logArea = (TextView) findViewById(R.id.log_area); logArea.setMovementMethod(new ScrollingMovementMethod()); coolmic = new CoolMic(this, "default"); if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) { if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Log.d("WrapperInit", Wrapper.getInitException().toString()); Toast.makeText(getApplicationContext(), "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT) .show(); } } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Toast.makeText(getApplicationContext(), "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT) .show(); } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) { Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT) .show(); } txtListeners = (TextView) findViewById(R.id.txtListeners); IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE); LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter); }
From source file:org.mariotaku.twidere.service.RefreshService.java
@Override public void onCreate() { super.onCreate(); GeneralComponentHelper.build(this).inject(this); mAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); mPendingRefreshHomeTimelineIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_HOME_TIMELINE), 0); mPendingRefreshMentionsIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_NOTIFICATIONS), 0); mPendingRefreshDirectMessagesIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_DIRECT_MESSAGES), 0); mPendingRefreshTrendsIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_TRENDS), 0); final IntentFilter refreshFilter = new IntentFilter(BROADCAST_NOTIFICATION_DELETED); refreshFilter.addAction(BROADCAST_REFRESH_HOME_TIMELINE); refreshFilter.addAction(BROADCAST_REFRESH_NOTIFICATIONS); refreshFilter.addAction(BROADCAST_REFRESH_DIRECT_MESSAGES); refreshFilter.addAction(BROADCAST_RESCHEDULE_HOME_TIMELINE_REFRESHING); refreshFilter.addAction(BROADCAST_RESCHEDULE_MENTIONS_REFRESHING); refreshFilter.addAction(BROADCAST_RESCHEDULE_DIRECT_MESSAGES_REFRESHING); registerReceiver(mStateReceiver, refreshFilter); final IntentFilter batteryFilter = new IntentFilter(); batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED); batteryFilter.addAction(Intent.ACTION_BATTERY_OKAY); batteryFilter.addAction(Intent.ACTION_BATTERY_LOW); batteryFilter.addAction(Intent.ACTION_POWER_CONNECTED); batteryFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); final IntentFilter screenFilter = new IntentFilter(); screenFilter.addAction(Intent.ACTION_SCREEN_ON); screenFilter.addAction(Intent.ACTION_SCREEN_OFF); screenFilter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mPowerStateReceiver, batteryFilter); registerReceiver(mScreenStateReceiver, screenFilter); PowerStateReceiver.setServiceReceiverStarted(true); if (Utils.hasAutoRefreshAccounts(this)) { startAutoRefresh();/* w w w .jav a 2s . c o m*/ } else { stopSelf(); } }
From source file:net.naonedbus.appwidget.HoraireWidgetProvider.java
/** * Grer le signal de rafraichissement.//ww w.j av a 2s .c om */ @Override public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "onReceive " + action); final boolean updateWidget = ACTION_APPWIDGET_UPDATE.equals(action) || Intent.ACTION_USER_PRESENT.equals(action); if (updateWidget) { final int idExtra = intent.getIntExtra("id", -1); int[] ids; if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "Rception de l'ordre de rafraichissement des widgets."); if (idExtra == -1) { ids = appWidgetManager.getAppWidgetIds(new ComponentName(context, this.getClass())); } else { ids = new int[] { idExtra }; } onUpdate(context, appWidgetManager, ids); } else if (HoraireWidgetProvider.ACTION_APPWIDGET_ON_CLICK.equals(action)) { final Arret arret = intent.getParcelableExtra("favori"); if (arret != null) { final ParamIntent startIntent = new ParamIntent(context, HorairesActivity.class); startIntent.putExtra(HorairesActivity.PARAM_ARRET, arret); startIntent.putExtra(HorairesActivity.PARAM_FROM_WIDGET, true); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntentWithParentStack(startIntent); stackBuilder.startActivities(); } } super.onReceive(context, intent); }
From source file:com.dudu.aios.ui.activity.MainRecordActivity.java
private void registerScreenReceiver() { mScreenReceiver = new ScreenReceiver(); IntentFilter filter = new IntentFilter(); // ???//from w ww . j a v a 2 s . co m filter.addAction(Intent.ACTION_SCREEN_OFF); // ?? filter.addAction(Intent.ACTION_SCREEN_ON); // ?? filter.addAction(Intent.ACTION_USER_PRESENT); // ?????? // example????????? // ????pad?? filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mScreenReceiver, filter); }