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:net.frygo.findmybuddy.GCMIntentService.java
private static void generateAcceptfriendNotification(Context context, String message, String status) { Random rand = new Random(); int x = rand.nextInt(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, customlistview.class); if (status.equalsIgnoreCase("accept")) message = message + " added you as buddy"; else/*from w w w . j av a 2 s. c o m*/ message = message + " rejected you as buddy"; PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(x, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock mWakelock = pm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title); mWakelock.acquire(); // Timer before putting Android Device to sleep mode. Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() { mWakelock.release(); } }; timer.schedule(task, 5000); }
From source file:it.evilsocket.dsploit.core.System.java
public static void init(Context context) throws Exception { mContext = context;//from www. jav a2s . c o m try { mStoragePath = getSettings().getString("PREF_SAVE_PATH", Environment.getExternalStorageDirectory().toString()); mSessionName = "dsploit-session-" + java.lang.System.currentTimeMillis(); mUpdateManager = new UpdateManager(mContext); mPlugins = new ArrayList<Plugin>(); mTargets = new Vector<Target>(); mOpenPorts = new SparseIntArray(3); // if we are here, network initialization didn't throw any error, lock wifi WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); if (mWifiLock == null) mWifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "wifiLock"); if (mWifiLock.isHeld() == false) mWifiLock.acquire(); // wake lock if enabled if (getSettings().getBoolean("PREF_WAKE_LOCK", true) == true) { PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); if (mWakeLock == null) mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "wakeLock"); if (mWakeLock.isHeld() == false) mWakeLock.acquire(); } // set ports try { HTTP_PROXY_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_PROXY_PORT", "8080")); HTTP_SERVER_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_SERVER_PORT", "8081")); HTTPS_REDIR_PORT = Integer.parseInt(getSettings().getString("PREF_HTTPS_REDIRECTOR_PORT", "8082")); } catch (NumberFormatException e) { HTTP_PROXY_PORT = 8080; HTTP_SERVER_PORT = 8081; HTTPS_REDIR_PORT = 8082; } mNmap = new NMap(mContext); mArpSpoof = new ArpSpoof(mContext); mEttercap = new Ettercap(mContext); mIptables = new IPTables(); mHydra = new Hydra(mContext); mTcpdump = new TcpDump(mContext); // initialize network data at the end mNetwork = new Network(mContext); Target network = new Target(mNetwork), gateway = new Target(mNetwork.getGatewayAddress(), mNetwork.getGatewayHardware()), device = new Target(mNetwork.getLocalAddress(), mNetwork.getLocalHardware()); gateway.setAlias(mNetwork.getSSID()); device.setAlias(android.os.Build.MODEL); mTargets.add(network); mTargets.add(gateway); mTargets.add(device); mInitialized = true; } catch (Exception e) { errorLogging(TAG, e); throw 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 .jav a 2 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.ti.sensortag.gui.services.ServicesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakelockk = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock"); setContentView(R.layout.services_browser); //for checking signal strength.. MyListener = new MyPhoneStateListener(); Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); //ends..// w w w.ja va 2 s . c om StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); test_1 = getIntent().getStringExtra("TEST"); Toast.makeText(getBaseContext(), "ARV in services SA :" + test_1, Toast.LENGTH_SHORT).show(); /* sendbutton = (Button) findViewById(R.id.button1); sendbutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String sensorid = test_1; String sensortype = "temperature"; BufferedReader br = null; try { String sCurrentLine; File ext = Environment.getExternalStorageDirectory(); File myFile = new File(ext, "mysdfile_25.txt"); br = new BufferedReader(new FileReader(myFile)); while ((sCurrentLine = br.readLine()) != null) { String[] numberSplit = sCurrentLine.split(":") ; String time = numberSplit[ (numberSplit.length-2) ] ; String val = numberSplit[ (numberSplit.length-1) ] ; //System.out.println(sCurrentLine); HttpResponse httpresponse; //int responsecode; StatusLine responsecode; String strresp; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://rnicu-cloud.appspot.com/sensor/update"); try{ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("sensorid", sensorid)); nameValuePairs.add(new BasicNameValuePair("sensortype", sensortype)); nameValuePairs.add(new BasicNameValuePair("time", time)); nameValuePairs.add(new BasicNameValuePair("val", val)); // try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // try { httpresponse = httpclient.execute(httppost); //responsecode = httpresponse.getStatusLine().getStatusCode(); responsecode = httpresponse.getStatusLine(); strresp = responsecode.toString(); Log.d("ARV Response msg from post", httpresponse.toString()); Log.d("ARV status of post", strresp); HttpEntity httpentity = httpresponse.getEntity(); Log.d("ARV entity string", EntityUtils.toString(httpentity)); // Log.d("ARV oly entity", httpentity.toString()); // Log.d("ARV Entity response", httpentity.getContent().toString()); //httpclient.execute(httppost); Toast.makeText(getApplicationContext(), "Posted data and returned value:"+ strresp, Toast.LENGTH_LONG).show(); // } catch (ClientProtocolException e) { // TODO Auto-generated catch block // e.printStackTrace(); // } catch (IOException e) { // TODO Auto-generated catch block // e.printStackTrace(); // } // } }catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } finally { try { if (br != null)br.close(); } catch (IOException ex) { ex.printStackTrace(); } } // Toast.makeText(getApplicationContext(), "Entered on click", Toast.LENGTH_SHORT).show(); /*catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });*/ getActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.mowares.massagerexpressclient.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from w ww . j a v a2 s . co 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.simicart.core.notification.GCMIntentService.java
private void onRecieveMessage(Context context) { // Sang man hinh khi co notification PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000);/*www . jav a 2s .c o m*/ // // Am thanh mac dinh // try { // Uri notification = RingtoneManager // .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), // notification); // r.play(); // } catch (Exception e) { // e.printStackTrace(); // } // check app open or close if (MainActivity.context != null && MainActivity.state != MainActivity.PAUSE && notificationData.getShowPopup().equals("1")) { createNotification(context); } else { generateNotification(context, notificationData); } }
From source file:org.csploit.android.core.System.java
public static void init(Context context) throws Exception { mContext = context;//from w w w . java 2 s . com try { Logger.debug("initializing System..."); mStoragePath = getSettings().getString("PREF_SAVE_PATH", Environment.getExternalStorageDirectory().toString()); mSessionName = "csploit-session-" + java.lang.System.currentTimeMillis(); mKnownIssues = new KnownIssues(); mPlugins = new ArrayList<>(); mOpenPorts = new SparseIntArray(3); mServices = new HashMap<>(); mPorts = new HashMap<>(); // if we are here, network initialization didn't throw any error, lock wifi WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); if (mWifiLock == null) mWifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "wifiLock"); if (!mWifiLock.isHeld()) mWifiLock.acquire(); // wake lock if enabled if (getSettings().getBoolean("PREF_WAKE_LOCK", true)) { PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); if (mWakeLock == null) mWakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "wakeLock"); if (!mWakeLock.isHeld()) mWakeLock.acquire(); } // set ports try { HTTP_PROXY_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_PROXY_PORT", "8080")); HTTP_SERVER_PORT = Integer.parseInt(getSettings().getString("PREF_HTTP_SERVER_PORT", "8081")); HTTPS_REDIR_PORT = Integer.parseInt(getSettings().getString("PREF_HTTPS_REDIRECTOR_PORT", "8082")); MSF_RPC_PORT = Integer.parseInt(getSettings().getString("MSF_RPC_PORT", "55553")); } catch (NumberFormatException e) { HTTP_PROXY_PORT = 8080; HTTP_SERVER_PORT = 8081; HTTPS_REDIR_PORT = 8082; MSF_RPC_PORT = 55553; } uncaughtReloadNetworkMapping(); ThreadHelper.getSharedExecutor().execute(new Runnable() { @Override public void run() { preloadServices(); preloadVendors(); } }); } catch (Exception e) { if (!(e instanceof NoRouteToHostException)) errorLogging(e); throw e; } }
From source file:com.arifin.taxi.penumpang.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//* ww w . j a v a 2 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); 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(); }
From source file:org.interactiverobotics.headset_launcher.LauncherService.java
/** * ?./* ww w .j av a 2s . c o m*/ * */ @SuppressWarnings("deprecation") private void unlockScreen() { final KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); mKeyguardLock = keyguardManager.newKeyguardLock("HeadsetLauncherLock"); mKeyguardLock.disableKeyguard(); final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "HeadsetLauncherWakeLock"); mWakeLock.acquire(); // ? ? ? mTimeoutHandler.postDelayed(mTimeoutRunnable, Constants.NOTIFICATION_TIMEOUT * 1000); }
From source file:com.linroid.pushapp.service.DownloadService.java
/** * ?//from w w w.j ava 2 s . com * @param pack */ private void onDownloadComplete(Pack pack) { Timber.d("%s ?,?:%s", pack.getAppName(), pack.getPath()); int toastResId = R.string.toast_download_complete; if (autoInstall.getValue()) { startActivity(IntentUtil.installApk(pack.getPath())); if (AndroidUtil.isAccessibilitySettingsOn(this, ApkAutoInstallService.class.getCanonicalName())) { PowerManager powermanager = ((PowerManager) getSystemService(Context.POWER_SERVICE)); PowerManager.WakeLock wakeLock = powermanager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "Install Worker, FULL WAKE LOCK"); wakeLock.acquire(); wakeLock.release(); KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); // if(keyguardManager.isDeviceLocked()) { final KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock"); keyguardLock.disableKeyguard(); // } ApkAutoInstallService.addInstallPackage(pack); toastResId = R.string.toast_start_install; } else { toastResId = R.string.toast_download_complete; } } Toast.makeText(this, getString(toastResId, pack.getAppName()), Toast.LENGTH_SHORT).show(); }