List of usage examples for android.content Intent ACTION_SCREEN_ON
String ACTION_SCREEN_ON
To view the source code for android.content Intent ACTION_SCREEN_ON.
Click Source Link
From source file:org.linphone.LinphoneService.java
@Override public void onCreate() { super.onCreate(); theLinphone = this; // Dump some debugging information to the logs Hacks.dumpDeviceInformation();//from w w w. j a va2 s .c om addCallListner(); // tryTogetLastReceive(); // tryTogetLastRequest(); tryKeepOnline(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotification = new Notification(R.drawable.status_level, "", System.currentTimeMillis()); mNotification.iconLevel = IC_LEVEL_ORANGE; mNotification.flags |= Notification.FLAG_ONGOING_EVENT; Intent notificationIntent = new Intent(this, MainViewActivity.class); mNofificationContentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mNotification.setLatestEventInfo(this, NOTIFICATION_TITLE, "", mNofificationContentIntent); mNotificationManager.notify(NOTIFICATION_ID, mNotification); mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mAudioManager = ((AudioManager) getSystemService(Context.AUDIO_SERVICE)); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); try { copyAssetsFromPackage(); mLinphoneCore = LinphoneCoreFactory.instance().createLinphoneCore(this, LINPHONE_RC, LINPHONE_FACTORY_RC, null); mLinphoneCore.setPlaybackGain(3); mLinphoneCore.setRing(null); try { initFromConf(); } catch (LinphoneException e) { Log.w(TAG, "no config ready yet"); } TimerTask lTask = new TimerTask() { @Override public void run() { mLinphoneCore.iterate(); } }; mTimer.scheduleAtFixedRate(lTask, 0, 100); IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); lFilter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(mKeepAliveMgrReceiver, lFilter); } catch (Exception e) { Log.e(TAG, "Cannot start linphone", e); } }
From source file:com.paywith.ibeacon.service.IBeaconService.java
@Override public void onCreate() { //Log.i(TAG, "iBeaconService version "+ BuildConfig.VERSION_NAME+" is starting up"); getBluetoothAdapter();/*w w w . ja v a2 s.c om*/ bluetoothCrashResolver = new BluetoothCrashResolver(this); bluetoothCrashResolver.start(); setupApiConnection(); // Look for simulated scan data try { Class klass = Class.forName("com.paywith.ibeacon.SimulatedScanData"); java.lang.reflect.Field f = klass.getField("iBeacons"); this.simulatedScanData = (List<IBeacon>) f.get(null); } catch (ClassNotFoundException e) { if (IBeaconManager.debug) Log.d(TAG, "No com.paywith.ibeacon.SimulatedScanData class exists."); } catch (Exception e) { Log.e(TAG, "Cannot get simulated Scan data. Make sure your com.paywith.ibeacon.SimulatedScanData class defines a field with the signature 'public static List<IBeacon> iBeacons'", e); } IntentFilter theFilter = new IntentFilter(); theFilter.addAction(Intent.ACTION_SCREEN_OFF); theFilter.addAction(Intent.ACTION_SCREEN_ON); this.context = this.getBaseContext(); settings = context.getSharedPreferences(PREFERENCES, 0); editor = settings.edit(); }
From source file:com.mobicage.rogerthat.MainService.java
@Override public void onCreate() { super.onCreate(); L.d(getPackageName() + "::MainService.OnCreate"); try {// w ww. j a v a 2 s . com PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); mIsDebug = (info.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; } catch (Exception e) { Log.e(L.TAG, "Forcing debug=false"); mIsDebug = false; } T.setUIThread("MainService.onCreate()"); L.setContext(this); patchIPSettingsForDNSSRV(); mIntentStash = new ArrayList<Intent>(); mHighPriorityIntents = new HashSet<String>(); mHighPriorityIntents.add(CLOSE_ACTIVITY_INTENT); mRunnableStash = new ArrayList<SafeRunnable>(); readVersion(); mUIHandler = new Handler(); createIOWorkerThread(); createHttpWorkerThread(); mBinder = new MainBinder(); setupDatabase(); setupConfiguration(); boolean debugLoggingEnabled = isDebugLoggingEnabled(); if (debugLoggingEnabled) { mLOCSDCardLogger = new SDCardLogger(MainService.this, "location_log.txt", "LOC"); } mGeoLocationProvider = new GeoLocationProvider(this, mConfigProvider, mLOCSDCardLogger); setupNetworkConnectivityManager(); setupRPC(); startAwakeLogger(); if (debugLoggingEnabled) { mHTTPSDCardLogger = new SDCardLogger(MainService.this, "httplog.txt", "HTTP"); mXMPPSDCardLogger = new SDCardLogger(MainService.this, "xmpplog.txt", "XMPP"); } final boolean mustInitializeAndStartService = getRegisteredFromConfig(); if (mustInitializeAndStartService) { setupNetworkProtocol(); initializeService(null); startMainService(START_INTENT_FROM_ONCREATE_KEY); } processUncaughtExceptions(mustInitializeAndStartService); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(INTENT_SHOULD_CLEANUP_CACHED_FILES); registerReceiver(mBroadcastReceiver, filter); final PowerManager pow = (PowerManager) getSystemService(POWER_SERVICE); mScreenIsOn = pow.isScreenOn(); hideLogForwardNotification(); // This should remain the last line of this method. current = this; }
From source file:org.durka.hallmonitor.CoreStateManager.java
public void registerCoreReceiver() { if (mCoreReceiver == null) { /*// w ww . j a v a 2s .co m * HEADSET_PLUG, SCREEN_ON and SCREEN_OFF only available through * registerReceiver function */ mCoreReceiver = new CoreReceiver(); IntentFilter intfil = new IntentFilter(); intfil.setPriority(990); intfil.addAction(Intent.ACTION_HEADSET_PLUG); intfil.addAction(Intent.ACTION_SCREEN_ON); intfil.addAction(Intent.ACTION_SCREEN_OFF); if (preference_all.getBoolean("pref_internalservice", false)) { IntentFilter mIntentFilter = new IntentFilter(); mIntentFilter.addAction(getActionCover()); LocalBroadcastManager.getInstance(mAppContext).registerReceiver(mCoreReceiver, mIntentFilter); } else { intfil.addAction(CoreReceiver.ACTION_LID_STATE_CHANGED); } mAppContext.registerReceiver(mCoreReceiver, intfil); } }
From source file:org.pixmob.freemobile.netstat.MonitorService.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* ww w .j av a 2 s .c om*/ public void onCreate() { super.onCreate(); pm = (PowerManager) getSystemService(POWER_SERVICE); tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); prefs = getSharedPreferences(SP_NAME, MODE_PRIVATE); prefs.registerOnSharedPreferenceChangeListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { final int largeIconWidth = getResources() .getDimensionPixelSize(android.R.dimen.notification_large_icon_width); final int largeIconHeight = getResources() .getDimensionPixelSize(android.R.dimen.notification_large_icon_height); if ((largeIconWidth > 0) && (largeIconHeight > 0)) { Bitmap freeLargeIconTmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_notify_service_free_large); if ((freeLargeIconTmp != null) && (freeLargeIconTmp.getWidth() > 0) && (freeLargeIconTmp.getHeight() > 0)) { freeLargeIcon = Bitmap.createScaledBitmap(freeLargeIconTmp, largeIconWidth, largeIconHeight, true); } Bitmap freeFemtoLargeIconTmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_notify_service_free_femto_large); if ((freeFemtoLargeIconTmp != null) && (freeFemtoLargeIconTmp.getHeight() > 0) && (freeFemtoLargeIconTmp.getWidth() > 0)) { freeFemtoLargeIcon = Bitmap.createScaledBitmap(freeFemtoLargeIconTmp, largeIconWidth, largeIconHeight, true); } Bitmap orangeLargeIconTmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_notify_service_orange_large); if ((orangeLargeIconTmp != null) && (orangeLargeIconTmp.getHeight() > 0) && (orangeLargeIconTmp.getWidth() > 0)) { orangeLargeIcon = Bitmap.createScaledBitmap(orangeLargeIconTmp, largeIconWidth, largeIconHeight, true); } } } // Initialize and start a worker thread for inserting rows into the // application database. final Context c = getApplicationContext(); pendingInsert = new ArrayBlockingQueue<>(8); new PendingInsertWorker(c, pendingInsert).start(); // This intent is fired when the application notification is clicked. openUIPendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_NOTIFICATION), PendingIntent.FLAG_CANCEL_CURRENT); // This intent is only available as a Jelly Bean notification action in // order to open network operator settings. Intent networkSettingsIntent = IntentFactory.networkOperatorSettings(this); if (networkSettingsIntent != null) { networkOperatorSettingsPendingIntent = PendingIntent.getActivity(this, 0, networkSettingsIntent, PendingIntent.FLAG_CANCEL_CURRENT); } Intent wirelessSettingsIntent = IntentFactory.wirelessSettings(this); if (wirelessSettingsIntent != null) { wirelessSettingsPendingIntent = PendingIntent.getActivity(this, 0, wirelessSettingsIntent, PendingIntent.FLAG_CANCEL_CURRENT); } // Watch screen light: is the screen on? screenMonitor = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateEventDatabase(); } }; final IntentFilter screenIntentFilter = new IntentFilter(); screenIntentFilter.addAction(Intent.ACTION_SCREEN_ON); screenIntentFilter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenMonitor, screenIntentFilter); // Watch Wi-Fi connections. connectionMonitor = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (onConnectivityUpdated()) { updateEventDatabase(); } } }; final IntentFilter connectionIntentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(connectionMonitor, connectionIntentFilter); // Watch mobile connections. phoneMonitor = new PhoneStateListener() { @Override public void onDataConnectionStateChanged(int state, int networkType) { updateService(); } @Override public void onServiceStateChanged(ServiceState serviceState) { if (stopServiceIfSimOperatorIsNotFreeMobile()) return; mobileNetworkConnected = (serviceState != null) && (serviceState.getState() == ServiceState.STATE_IN_SERVICE); updateService(); } @Override public void onCellInfoChanged(List<CellInfo> cellInfo) { updateService(); } private void updateService() { if (tm != null) { // Fix NPE - found by Acralyzer mobileNetworkType = tm.getNetworkType(); //update the network type to have the latest } final int phoneStateUpdated = onPhoneStateUpdated(); if (phoneStateUpdated >= 0) updateEventDatabase(); updateNotification(true, phoneStateUpdated == 1); } }; int events = PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) events |= PhoneStateListener.LISTEN_CELL_INFO; tm.listen(phoneMonitor, events); // Watch battery level. batteryMonitor = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateEventDatabase(); } }; batteryIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(batteryMonitor, batteryIntentFilter); shutdownMonitor = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onDeviceShutdown(); } }; final IntentFilter shutdownIntentFilter = new IntentFilter(); shutdownIntentFilter.addAction(Intent.ACTION_SHUTDOWN); // HTC devices use a different Intent action: // http://stackoverflow.com/q/5076410/422906 shutdownIntentFilter.addAction("android.intent.action.QUICKBOOT_POWEROFF"); registerReceiver(shutdownMonitor, shutdownIntentFilter); if (prefs.getBoolean(SP_KEY_ENABLE_AUTO_RESTART_SERVICE, false) && Arrays .asList(ANDROID_VERSIONS_ALLOWED_TO_AUTO_RESTART_SERVICE).contains(Build.VERSION.RELEASE)) { // Kitkat and JellyBean auto-kill service workaround // http://stackoverflow.com/a/20735519/1527491 ensureServiceStaysRunning(); } }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override//from w w w .j a v a 2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); suggestionsTimer = new Timer("suggestions-timer"); countdownTimer = new Timer("messsage-countdown-timer"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenReceiver, filter); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC)); cloud.recycle(); } } setContentView(R.layout.activity_message); try { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); } catch (Throwable t) { } suggestionsAdapter = new SuggestionsAdapter(); progressBar = (ProgressBar) findViewById(R.id.progress); errorMsg = (TextView) findViewById(R.id.errorMsg); buffersListView = findViewById(R.id.BuffersList); messageContainer = (LinearLayout) findViewById(R.id.messageContainer); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); redColor = getResources().getColor(R.color.highlight_red); blueColor = getResources().getColor(R.color.dark_blue); messageTxt = (ActionEditText) findViewById(R.id.messageTxt); messageTxt.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.getAction() == KeyEvent.ACTION_DOWN) nextSuggestion(); return true; } return false; } }); messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (drawerLayout != null && v == messageTxt && hasFocus) { drawerLayout.closeDrawers(); update_suggestions(false); } else if (!hasFocus) { runOnUiThread(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); } }); } } }); messageTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (drawerLayout != null) { drawerLayout.closeDrawers(); } } }); messageTxt.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } return true; } }); textWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Object[] spans = s.getSpans(0, s.length(), Object.class); for (Object o : spans) { if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING) && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class || o.getClass() == BackgroundColorSpan.class || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) { s.removeSpan(o); } } if (s.length() > 0 && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } else { sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); } String text = s.toString(); if (text.endsWith("\t")) { //Workaround for Swype text = text.substring(0, text.length() - 1); messageTxt.setText(text); nextSuggestion(); } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) { runOnUiThread(new Runnable() { @Override public void run() { update_suggestions(false); } }); } else { if (suggestionsTimer != null) { if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); suggestionsTimerTask = new TimerTask() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); update_suggestions(false); } }; suggestionsTimer.schedule(suggestionsTimerTask, 250); } } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; messageTxt.addTextChangedListener(textWatcher); sendBtn = findViewById(R.id.sendBtn); sendBtn.setFocusable(false); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) new SendTask().execute((Void) null); } }); photoBtn = findViewById(R.id.photoBtn); if (photoBtn != null) { photoBtn.setFocusable(false); photoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertPhoto(); } }); } userListView = findViewById(R.id.usersListFragment); View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null); v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { show_topic_popup(); } }); if (drawerLayout != null) { if (findViewById(R.id.usersListFragment2) == null) { upDrawable = new DrawerArrowDrawable(this); greyColor = upDrawable.getColor(); ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable); ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer"); drawerLayout.setDrawerListener(mDrawerListener); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } } messageTxt.setDrawerLayout(drawerLayout); title = (TextView) v.findViewById(R.id.title); subtitle = (TextView) v.findViewById(R.id.subtitle); key = (ImageView) v.findViewById(R.id.key); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid")); backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack"); } if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri")) imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri")); else imageCaptureURI = null; ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance(); if (config != null) { imgurTask = config.imgurUploadTask; fileUploadTask = config.fileUploadTask; } drawerLayout.setScrimColor(0); drawerLayout.closeDrawers(); getSupportActionBar().setElevation(0); }
From source file:co.beem.project.beem.FacebookTextService.java
/** * {@inheritDoc}/*from w ww .j a va 2s. co m*/ */ @Override public void onCreate() { super.onCreate(); smackAndroid = SmackAndroid.init(FacebookTextService.this); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); savingMessageQueue = new LinkedBlockingQueue<co.beem.project.beem.service.Message>(); loadingUserAvatarQueue = new LinkedBlockingDeque<String>(); stateChangeQueue = new LinkedBlockingQueue<User>(); databaseHelper = getHelper(); try { setupDatabaseConnection(); } catch (Exception e) { e.printStackTrace(); } isRunning = true; sessionManager = new SessionManager(FacebookTextService.this); savingMessageOnBackgroundThread(new SavingNewMessageTask()); savingMessageOnBackgroundThread(new UpdateUserStateTask()); handler = new Handler(); registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); registerReceiver(mOnOffReceiver, new IntentFilter(FacebookTextApplication.GET_AVATAR)); registerReceiver(mOnOffReceiver, new IntentFilter(FacebookTextApplication.UPDATE_USER_STATE)); registerReceiver(mOnOffReceiver, new IntentFilter(FacebookTextApplication.PUSH_NOTIFICATION_FAVORITE_ONLINE)); mSettings = PreferenceManager.getDefaultSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener); if (mSettings.getBoolean(FacebookTextApplication.USE_AUTO_AWAY_KEY, false)) { mOnOffReceiverIsRegistered = true; registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); // registerReceiver(sma, filter) } String tmpJid = mSettings.getString(FacebookTextApplication.ACCOUNT_USERNAME_KEY, "").trim(); mLogin = StringUtils.parseName(tmpJid); boolean useSystemAccount = mSettings.getBoolean(FacebookTextApplication.USE_SYSTEM_ACCOUNT_KEY, false); mPort = DEFAULT_XMPP_PORT; mService = StringUtils.parseServer(tmpJid); mHost = mService; initMemorizingTrustManager(); if (mSettings.getBoolean(FacebookTextApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) { mHost = mSettings.getString(FacebookTextApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "").trim(); if ("".equals(mHost)) mHost = mService; String tmpPort = mSettings.getString(FacebookTextApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222"); if (!"".equals(tmpPort)) mPort = Integer.parseInt(tmpPort); } if (mSettings.getBoolean(FacebookTextApplication.FULL_JID_LOGIN_KEY, false) || "gmail.com".equals(mService) || "googlemail.com".equals(mService) || useSystemAccount) { mLogin = tmpJid; } configure(ProviderManager.getInstance()); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Roster.setDefaultSubscriptionMode(SubscriptionMode.manual); mBind = new XmppFacade(this); savingMessageOnBackgroundThread(new DownloadAvatarTask()); Log.d(TAG, "Create FacebookTextService \t id: " + mLogin + " \t host: " + mHost + "\tmPort" + mPort + "\t service" + mService); }
From source file:com.androzic.MapFragment.java
@Override public void onResume() { super.onResume(); Log.e(TAG, "onResume()"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity()); onSharedPreferenceChanged(settings, getString(R.string.pref_maprenderinterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapfollowonloc)); onSharedPreferenceChanged(settings, getString(R.string.pref_wakelock)); onSharedPreferenceChanged(settings, getString(R.string.pref_showdistance_int)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidemapinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidesatinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidenavinfo)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdiminterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdimvalue)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdim)); onSharedPreferenceChanged(settings, getString(R.string.pref_unfollowontap)); onSharedPreferenceChanged(settings, getString(R.string.pref_lookahead)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapbest)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapbestinterval)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarbg)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_scalebarbgcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_hidemapcross)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapcrosscolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_cursorvector)); onSharedPreferenceChanged(settings, getString(R.string.pref_cursorcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_navigation_proximity)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitspeed)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitelevation)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitangle)); PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this); updateEditStatus();/*from w ww .j a va2 s . c o m*/ updateGPSStatus(); onUpdateNavigationState(); onUpdateNavigationStatus(); application.registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATUS)); application.registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATE)); application.registerReceiver(broadcastReceiver, new IntentFilter(LocationService.BROADCAST_LOCATING_STATUS)); application.registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); application.registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); map.setKeepScreenOn(keepScreenOn); map.setFollowing(following); mapButtonsVisible = settings.getBoolean(getString(R.string.ui_mapbuttons_shown), true); mapButtons.setVisibility(mapButtonsVisible ? View.VISIBLE : View.GONE); updateMapViewArea(); // Start updating UI map.resume(); map.updateMapInfo(); map.updateMapCenter(); map.requestFocus(); updateCallback.post(updateUI); }
From source file:saphion.services.ForegroundService.java
protected void triggerFunc(String action) { if (action == Intent.ACTION_SCREEN_OFF) { PowerProfItems pItems = PowerPreference.retPower(getBaseContext()) .get(mPref.getInt(PreferenceHelper.POSITIONS, 0)); if (pItems.getData()) { if (pItems.getS_Off_mdata()) { mVal = pItems.getS_Off_int_mdata(); if (ToggleHelper.isDataEnable(getBaseContext())) { try { ToggleHelper.toggleMData(getBaseContext()); } catch (Exception e) { e.printStackTrace(); }/*from w w w .j a v a 2 s. co m*/ } if (mVal != -99) { Log.d("Posting dataOnRunnable with mVal: " + mVal + " and millies of " + (mVal * 60 * 1000)); handler.postDelayed(dataOnRunnable, mVal * 60 * 1000); } else { Log.d("Won't post because mVal is: " + mVal); } } } if (pItems.getWifi()) { if (pItems.getS_Off_wifi()) { wVal = pItems.getS_Off_int_wifi(); if (ToggleHelper.isWifiEnabled(getBaseContext())) { ToggleHelper.toggleWifi(getBaseContext()); } if (wVal != -99) handler.postDelayed(wifiOnRunnable, wVal * 60 * 1000); } } } else if (action == Intent.ACTION_SCREEN_ON) { PowerProfItems pItems = PowerPreference.retPower(getBaseContext()) .get(mPref.getInt(PreferenceHelper.POSITIONS, 0)); handler.removeCallbacks(dataOffRunnable); handler.removeCallbacks(dataOnRunnable); handler.removeCallbacks(wifiOffRunnable); handler.removeCallbacks(wifiOnRunnable); if (pItems.getData()) { if (pItems.getS_Off_mdata()) { if (!ToggleHelper.isDataEnable(getBaseContext())) { try { ToggleHelper.toggleMData(getBaseContext()); } catch (Exception e) { e.printStackTrace(); } } } } if (pItems.getWifi()) { if (pItems.getS_Off_wifi()) { if (!ToggleHelper.isWifiEnabled(getBaseContext())) { ToggleHelper.toggleWifi(getBaseContext()); } } } } // Average stats processing // Log.Toast(getBaseContext(), "Recieved action", Toast.LENGTH_LONG); mPref = getSharedPreferences(PREF_NAME, MODE_MULTI_PROCESS); Editor mPrefEditor = mPref.edit(); Status mStat = readBatteryStat(); if ((mStat.getConnected() && mStat.getLevel() == 100) || action == Intent.ACTION_POWER_DISCONNECTED) { // Log.Toast(getBaseContext(), "Disconnected", Toast.LENGTH_LONG); int diff; if ((diff = mStat.getLevel() - mPref.getInt(PreferenceHelper.STAT_CONNECTED_LAST_LEVEL, mStat.getLevel())) > 3) { calcStat(mStat, mPref, mPrefEditor, diff, true); } if (mPref.getInt(PreferenceHelper.STAT_DISCONNECTED_LAST_LEVEL, -99) == -99 || diff < 3) { mPrefEditor.putInt(PreferenceHelper.STAT_DISCONNECTED_LAST_LEVEL, mStat.getLevel()); mPrefEditor.putString(PreferenceHelper.STAT_DISCONNECTED_LAST_TIME, TimeFuncs.getCurrentTimeStamp()); } } if ((!mStat.getConnected() && mStat.getLevel() <= 1) || action == Intent.ACTION_POWER_CONNECTED) { // Log.Toast(getBaseContext(), "Connected", Toast.LENGTH_LONG); int diff; if ((diff = mPref.getInt(PreferenceHelper.STAT_DISCONNECTED_LAST_LEVEL, mStat.getLevel()) - mStat.getLevel()) > 3) { calcStat(mStat, mPref, mPrefEditor, diff, false); } if (mPref.getInt(PreferenceHelper.STAT_CONNECTED_LAST_LEVEL, -99) == -99 || diff < 3) { mPrefEditor.putInt(PreferenceHelper.STAT_CONNECTED_LAST_LEVEL, mStat.getLevel()); mPrefEditor.putString(PreferenceHelper.STAT_CONNECTED_LAST_TIME, TimeFuncs.getCurrentTimeStamp()); } } mPrefEditor.commit(); }