List of usage examples for android.os PowerManager ON_AFTER_RELEASE
int ON_AFTER_RELEASE
To view the source code for android.os PowerManager ON_AFTER_RELEASE.
Click Source Link
From source file:com.rocketsingh.biker.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*from www .j a v a2 s . co m*/ public static void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MapActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(AndyConstants.NOTIFICATION_ID, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:com.example.slidingmenuexample.ui.NXTRemoteControl.java
/** Called when the activity is first created. */ @SuppressWarnings("deprecation") @Override/*from w w w. j ava 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); readPreferences(prefs, null); prefs.registerOnSharedPreferenceChangeListener(this); if (savedInstanceState != null) { mNewLaunch = false; mDeviceAddress = savedInstanceState.getString("device_address"); if (mDeviceAddress != null) { mSavedState = NXTTalker.STATE_CONNECTED; } if (savedInstanceState.containsKey("power")) { mPower = savedInstanceState.getInt("power"); } if (savedInstanceState.containsKey("controls_mode")) { mControlsMode = savedInstanceState.getInt("controls_mode"); } } mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "NXT Remote Control"); if (!NO_BT) { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } } setupUI(); mNXTTalker = new NXTTalker(mHandler); pagelist = getSlidingMenu(); pagelist.setShadowDrawable(R.drawable.shadow); pagelist.setBehindOffset(600); pagelist.setShadowWidth(15); pagelist.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setIcon(R.drawable.ic_launcher); if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new NXTRemoteControlView(); setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); setBehindContentView(R.layout.menu_frame); getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new MenuListPages()).commit(); setSlidingActionBarEnabled(true); }
From source file:com.android.talkback.eventprocessor.ProcessorVolumeStream.java
@SuppressWarnings("deprecation") public ProcessorVolumeStream(FeedbackController feedbackController, CursorController cursorController, DimScreenController dimScreenController, TalkBackService service) { if (feedbackController == null) throw new IllegalStateException("CachedFeedbackController is null"); if (cursorController == null) throw new IllegalStateException("CursorController is null"); if (dimScreenController == null) throw new IllegalStateException("DimScreenController is null"); mAudioManager = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE); mCursorController = cursorController; mFeedbackController = feedbackController; final PowerManager pm = (PowerManager) service.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, WL_TAG); mPrefs = SharedPreferencesUtils.getSharedPreferences(service); mService = service;//w w w .ja v a 2 s . c o m mDimScreenController = dimScreenController; mPatternDetector = new VolumeButtonPatternDetector(); mPatternDetector.setOnPatternMatchListener(this); }
From source file:cm.aptoide.pt.Aptoide.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); keepScreenOn = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "Full Power"); DownloadQueueServiceIntent = new Intent(getApplicationContext(), DownloadQueueService.class); startService(DownloadQueueServiceIntent); //@dsilveira #534 +10lines Check if Aptoide is already running to avoid wasting time and showing the splash ActivityManager activityManager = (ActivityManager) getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> running = activityManager.getRunningTasks(Integer.MAX_VALUE); for (RunningTaskInfo runningTask : running) { if (runningTask.baseActivity.getClassName().equals("cm.aptoide.pt.RemoteInTab")) { //RemoteInTab is the real Aptoide Activity Message msg = new Message(); msg.what = LOAD_TABS;/*from ww w .j a v a 2s . com*/ startHandler.sendMessage(msg); return; } } Log.d("Aptoide", "******* \n Downloads will be made to: " + Environment.getExternalStorageDirectory().getPath() + "\n ********"); sPref = getSharedPreferences("aptoide_prefs", MODE_PRIVATE); prefEdit = sPref.edit(); db = new DbHandler(this); PackageManager mPm = getPackageManager(); try { pkginfo = mPm.getPackageInfo("cm.aptoide.pt", 0); } catch (NameNotFoundException e) { } requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try { if (pkginfo.versionCode < Integer.parseInt(getXmlElement("versionCode"))) { Log.d("Aptoide-VersionCode", "Using version " + pkginfo.versionCode + ", suggest update!"); requestUpdateSelf(); } else { proceed(); } } catch (Exception e) { e.printStackTrace(); proceed(); } }
From source file:ti.modules.titanium.android.notificationmanager.NotificationManagerModule.java
@Kroll.method public void notify(int id, Object notificationValue) { NotificationProxy notificationProxy = NotificationProxy.fromObject(notificationValue); NotificationManager manager = getManager(); if (manager != null && notificationProxy != null) { // targeting Android O or above? create default channel try {/* www. ja v a 2 s. co m*/ notificationProxy.setCurrentId(id); Notification notification = notificationProxy.getNotification(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notification.getChannelId() == DEFAULT_CHANNEL_ID) { useDefaultChannel(); } getManager().notify(id, notification); HashMap wakeParams = notificationProxy.getWakeParams(); if (wakeParams != null) { int wakeTime = TiConvert.toInt(wakeParams.get("time"), 3000); int wakeFlags = TiConvert.toInt(wakeParams.get("flags"), (PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE)); PowerManager pm = (PowerManager) TiApplication.getInstance() .getSystemService(TiApplication.getInstance().getApplicationContext().POWER_SERVICE); if (pm != null && !pm.isScreenOn()) { try { WakeLock wl = pm.newWakeLock(wakeFlags, "TiWakeLock"); wl.acquire(wakeTime); } catch (IllegalArgumentException e) { Log.e(TAG, e.getMessage()); } } } } catch (Exception e) { } } }
From source file:com.automated.taxinow.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*w w w. j a va2 s. c o m*/ private void generateNotification(Context context, String message) { // System.out.println("this is message " + message); // System.out.println("NOTIFICATION RECEIVED!!!!!!!!!!!!!!" + message); int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainDrawerActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(0, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:com.mowares.massagerexpressclient.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///ww w.j av a2s . c o m private void generateNotification(Context context, String message) { // System.out.println("this is message " + message); // System.out.println("NOTIFICATION RECEIVED!!!!!!!!!!!!!!" + message); int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainDrawerActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); //notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(0, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.messagelist); Context context = getApplicationContext(); // Config checker alert dialog mConfigAlert = new AlertDialog.Builder(this).create(); mConfigAlert.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { startActivity(new Intent(MessageListActivity.this, OptionsActivity.class)); }//from w ww .j av a 2 s . c o m }); mNumUnread = 0; // Loaded in OnResume || threadMessagesFromDB() mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mOfflineMode = mPrefs.getBoolean("offlineMode", true); // Get the selected group from the GroupListActivity-passed bundle mTitleBar = (TextView) this.findViewById(R.id.topbar_text); mGroup = getIntent().getExtras().getString("selectedGroup"); mGroupID = DBUtils.getGroupIdFromName(mGroup, context); mGoGroups = (ImageButton) this.findViewById(R.id.btn_gogroups); mGoGroups.setOnClickListener(new OnClickListener() { public void onClick(View v) { MessageListActivity.this .startActivity(new Intent(MessageListActivity.this, GroupListActivity.class)); } }); mServerManager = new ServerManager(context); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "GroundhogThreading"); mMsgList = (ListView) this.findViewById(R.id.list_msgs); mMsgList.setOnItemClickListener(mListItemClickListener); registerForContextMenu(mMsgList); Drawable dw = getResources().getDrawable(R.drawable.greyline2); mMsgList.setDivider(dw); // Show the progress dialog, get messages from server, write to DB // and call the loading of message from DB and threading when it ends mWakeLock.acquire(); threadMessagesFromDB(); }
From source file:com.nbplus.vbroadlauncher.BaseActivity.java
public void acquireCpuWakeLock() { Log.e(TAG, "Acquiring cpu wake lock"); if (mCpuWakeLock != null) { return;//from ww w . java 2 s . c o m } PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "I'm your father"); mCpuWakeLock.acquire(); Window window = this.getWindow(); mDefaultWindowFlags = window.getAttributes().flags; window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); }
From source file:com.arifin.taxi.penumpang.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*from w w w .j a v a 2 s . c om*/ private void generateNotification(Context context, String message) { // System.out.println("this is message " + message); // System.out.println("NOTIFICATION RECEIVED!!!!!!!!!!!!!!" + message); int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainDrawerActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); notification = builder.setContentIntent(intent).setSmallIcon(icon).setTicker(message).setWhen(when) .setAutoCancel(true).setContentTitle(title).setContentText(message).build(); // mNM.notify(NOTIFICATION, notification); /*notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL;*/ System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(0, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }