List of usage examples for android.os PowerManager FULL_WAKE_LOCK
int FULL_WAKE_LOCK
To view the source code for android.os PowerManager FULL_WAKE_LOCK.
Click Source Link
From source file:com.endiansoftware.echo.remotewatch.GcmIntentService.java
private void sendNotification(Bundle msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(msg.get("key1").toString()) .setContentText(msg.get("key2").toString()).setTicker(msg.get("key1").toString()); mBuilder.setContentIntent(contentIntent); Notification notification = mBuilder.build(); if (msg.get("collapse_key").toString().equals("Emergency")) { notification.flags |= notification.FLAG_INSISTENT | notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_LIGHTS; notification.vibrate = new long[] { 100L, 100L, 200L, 500L }; } else {/*from ww w . java 2s . com*/ notification.flags |= notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_LIGHTS; notification.vibrate = new long[] { 100L }; } mNotificationManager.notify(NOTIFICATION_ID, notification); PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG"); wl.acquire(); }
From source file:com.wifi.brainbreaker.mydemo.spydroid.ui.SpydroidActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApplication = (SpydroidApplication) getApplication(); setContentView(R.layout.spydroid);//from w w w .j a v a 2s . c o m if (findViewById(R.id.handset_pager) != null) { // Handset detected ! mAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.handset_pager); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mSurfaceView = (SurfaceView) findViewById(R.id.handset_camera_view); SessionBuilder.getInstance().setSurfaceView(mSurfaceView); SessionBuilder.getInstance().setPreviewOrientation(90); } else { // Tablet detected ! device = TABLET; mAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.tablet_pager); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); SessionBuilder.getInstance().setPreviewOrientation(0); } mViewPager.setAdapter(mAdapter); // Remove the ads if this is the donate version of the app. // if (mApplication.DONATE_VERSION) { // ((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews(); // } // Prevents the phone from going to sleep mode PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock"); // Starts the service of the HTTP server this.startService(new Intent(this, CustomHttpServer.class)); // Starts the service of the RTSP server this.startService(new Intent(this, CustomRtspServer.class)); }
From source file:com.cellbots.local.EyesView.java
public EyesView(CellDroidActivity ct, String url, boolean torch) { Log.e("remote eyes", "started " + url); mParent = ct;// w w w . j av a2 s .c o m putUrl = url; PowerManager pm = (PowerManager) ct.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); out = new ByteArrayOutputStream(); if (putUrl != null) { isLocalUrl = putUrl.contains("127.0.0.1") || putUrl.contains("localhost"); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); mTorchMode = torch; resetConnection(); mHttpState = new HttpState(); } ct.setContentView(R.layout.eyes_main); mPreview = (SurfaceView) ct.findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; ct.registerReceiver(mReceiver, new IntentFilter(EyesView.EYES_COMMAND)); mFrame = (FrameLayout) ct.findViewById(R.id.eyes_frame); mImageView = new ImageView(ct); mImageView.setScaleType(ScaleType.FIT_CENTER); mImageView.setBackgroundColor(Color.BLACK); setPersona(PERSONA_READY); mFrame.addView(mImageView); }
From source file:net.majorkernelpanic.spydroid.ui.SpydroidActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApplication = (SpydroidApplication) getApplication(); setContentView(R.layout.spydroid);// ww w .j av a 2s. c om if (findViewById(R.id.handset_pager) != null) { // Handset detected ! mAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.handset_pager); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mSurfaceView = (SurfaceView) findViewById(R.id.handset_camera_view); SessionBuilder.getInstance().setSurfaceView(mSurfaceView); SessionBuilder.getInstance().setPreviewOrientation(90); } else { // Tablet detected ! device = TABLET; mAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.tablet_pager); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); SessionBuilder.getInstance().setPreviewOrientation(0); } mViewPager.setAdapter(mAdapter); // Remove the ads if this is the donate version of the app. if (mApplication.DONATE_VERSION) { ((LinearLayout) findViewById(R.id.adcontainer)).removeAllViews(); } // Prevents the phone from going to sleep mode PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock"); // Starts the service of the HTTP server this.startService(new Intent(this, CustomHttpServer.class)); // Starts the service of the RTSP server this.startService(new Intent(this, CustomRtspServer.class)); }
From source file:fr.bmartel.android.tictactoe.gcm.MyGcmListenerService.java
/** * Called when message is received.// w w w .ja va 2 s .c o m * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); if (from.startsWith("/topics/" + GameSingleton.DEVICE_ID)) { Log.d(TAG, "Message: " + message); try { JSONObject object = new JSONObject(message); ArrayList<String> eventItem = new ArrayList<>(); eventItem.add(object.toString()); broadcastUpdateStringList(BroadcastFilters.EVENT_MESSAGE, eventItem); if (!GameSingleton.activityForeground) { if (object.has(RequestConstants.DEVICE_MESSAGE_TOPIC) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID) && object.has(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)) { GameMessageTopic topic = GameMessageTopic .getTopic(object.getInt(RequestConstants.DEVICE_MESSAGE_TOPIC)); ChallengeMessage challengeMessage = new ChallengeMessage(topic, object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_ID), object.getString(RequestConstants.DEVICE_MESSAGE_CHALLENGER_NAME)); Log.i(TAG, "challenged by " + challengeMessage.getChallengerName() + " : " + challengeMessage.getChallengerId()); Intent intent2 = new Intent(this, DeviceListActivity.class); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Fight!") .setContentText("challenged by " + challengeMessage.getChallengerName()) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(new Random().nextInt(9999), notificationBuilder.build()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); boolean isScreenOn = pm.isScreenOn(); if (isScreenOn == false) { PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "MyLock"); wl.acquire(10000); PowerManager.WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyCpuLock"); wl_cpu.acquire(10000); } GameSingleton.pendingChallengeMessage = challengeMessage; GameSingleton.pendingChallenge = true; } } } catch (JSONException e) { e.printStackTrace(); } } }
From source file:com.cellbots.eyes.EyesActivity.java
/** Called when the activity is first created. */ @Override/*from w ww .j a v a 2 s . com*/ public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.eyes_main); mPreview = (SurfaceView) findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; this.registerReceiver(mReceiver, new IntentFilter(EyesActivity.EYES_COMMAND)); mFrame = (FrameLayout) findViewById(R.id.eyes_frame); mWebView = new WebView(this); mWebView.getSettings().setJavaScriptEnabled(true); // Use this if you want to load content locally // mWebView.loadUrl("content://com.cellbot.localpersonas/default/index.html"); mWebView.loadUrl("http://personabots.appspot.com/expressions/tuby"); mFrame.addView(mWebView); }
From source file:com.shrlnm.android.erm.ElmRenaultMonitor_Main.java
@Override public void onCreate(Bundle savedInstanceState) { //Enter full screen mode requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); if (D)/*from www . j av a 2 s .com*/ Log.e(TAG, "+++ ON CREATE +++"); powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "MyLock"); // Get local Bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } LocalBroadcastManager.getInstance(this).registerReceiver(localMessageReceiver, new IntentFilter("ElmRenaultMonitor_Main")); // there we will save the mac address of BT device for not to ask it again sharedPref = this.getSharedPreferences(getString(R.string.preference_addr_key), MODE_PRIVATE); // Set up the window layout //setContentView(R.layout.main); iv = new InstrumentsView(this); setContentView(iv); eRsp = new ecu(); }
From source file:com.rocketsingh.biker.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from w w w . j av a2 s . c o 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:it.technocontrolsystem.hypercontrol.gcm.HCGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. *///from w w w . jav a 2 s . c om private void sendNotification(Bundle data) { String messagetype = data.getString("messagetype"); switch (messagetype) { // crea una notifica che quando cliccata apre il site in allarme case "alarm": String siteUUID = data.getString("sitenum"); Site site = DB.getSiteByUUID(siteUUID); if (site != null) { Intent intent = new Intent(); intent.setClass(this, SiteActivity.class); intent.putExtra("siteid", site.getId()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); String title = "Allarme"; title += " " + site.getName(); // String msg = ""; // try { // int plantnum = Integer.parseInt(data.getString("plantnum")); // Plant plant = DB.getPlantBySiteAndNumber(siteid, plantnum); // msg += plant.getName(); // // int areanum = Integer.parseInt(data.getString("areanum")); // Area area = DB.getAreaByIdPlantAndAreaNumber(plant.getId(), areanum); // msg += " " + area.getName(); // // } catch (Exception e) { // } String msg = data.getString("message"); Uri defaultSoundUri = Lib.resourceToUri(R.raw.siren); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title).setContentText(msg) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); Notification mNotification = notificationBuilder.build(); mNotification.flags |= Notification.FLAG_INSISTENT; NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, mNotification); } else { Log.e(TAG, "site uuid " + siteUUID + " not found"); } break; // crea una notifica informativa case "info": // qui creare la notifica // ... break; } // dopo la notifica sveglia il device PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( (PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), getClass().getSimpleName()); wakeLock.acquire(); }
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 {//from w ww .java 2s. 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) { } } }