List of usage examples for android.telephony PhoneStateListener LISTEN_NONE
int LISTEN_NONE
To view the source code for android.telephony PhoneStateListener LISTEN_NONE.
Click Source Link
From source file:com.rks.musicx.services.MusicXService.java
@Override public void receiverCleanup() { if (controlReceiver != null) { try {// w ww . j a va 2 s . com unregisterReceiver(controlReceiver); } catch (Exception e) { e.printStackTrace(); } controlReceiver = null; } if (headsetListener != null) { try { unregisterReceiver(headsetListener); } catch (Exception e) { e.printStackTrace(); } headsetListener = null; } if (mediaButtonReceiver != null) { try { unregisterReceiver(mediaButtonReceiver); } catch (Exception e) { e.printStackTrace(); } mediaButtonReceiver = null; } if (telephonyManager != null) { telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); } }
From source file:com.marvin.rocklock.RockLockActivity.java
/** * Unregisters phone listeners/*from w ww .ja v a 2 s. com*/ */ private void unRegisterPhoneListener() { final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneListener, PhoneStateListener.LISTEN_NONE); }
From source file:com.github.jthuraisamy.yellowusage.ui.MainActivity.java
@Override public void onStop() { super.onStop(); // Remove LocalBroadcastManager listeners. LocalBroadcastManager.getInstance(this).unregisterReceiver(uiRefreshReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(asyncTaskReceiver); // Remove TelephonyManager listener. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); // Remove OnCheckedChangeListener on dataProtectionSwitch. dataProtectionSwitch.setOnCheckedChangeListener(null); // Remove PanelSlideListener on feesPanel. feesPanel.setPanelSlideListener(null); // Remove OnClickListener on bottomBar. bottomBar.setOnClickListener(null);//from w w w . j a va 2 s . com }
From source file:at.alladin.rmbt.android.util.InformationCollector.java
private void unregisterListeners() { Log.d(DEBUG_TAG, "unregistering listener"); if (telManager != null) { telManager.listen(telListener, PhoneStateListener.LISTEN_NONE); telListener = null;//from w w w . j a v a 2s. co m telManager = null; } }
From source file:com.SecUpwN.AIMSICD.service.AimsicdService.java
/** * Cell Information Tracking and database logging * * @param track Enable/Disable tracking//from w w w. jav a 2s . c o m */ public void setCellTracking(boolean track) { if (track) { tm.listen(mCellSignalListener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); if (lm != null) { mLocationListener = new MyLocationListener(); Log.i(TAG, "LocationManager already existed"); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MIN_UPDATE_TIME, GPS_MIN_UPDATE_DISTANCE, mLocationListener); } else { Log.i(TAG, "LocationManager did not exist"); lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); if (lm != null) { if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { Log.i(TAG, "LocationManager created"); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, GPS_MIN_UPDATE_TIME, GPS_MIN_UPDATE_DISTANCE, mLocationListener); } } } Helpers.msgShort(this, "Tracking cell information"); mTrackingCell = true; } else { tm.listen(mCellSignalListener, PhoneStateListener.LISTEN_NONE); lm.removeUpdates(mLocationListener); mDevice.mCell.setLon(0.0); mDevice.mCell.setLat(0.0); mTrackingCell = false; mDevice.setCellInfo("[0,0]|nn|nn|"); Helpers.msgShort(this, "Stopped tracking cell information"); } setNotification(); }
From source file:org.yammp.MusicPlaybackService.java
@Override public void onDestroy() { // Check that we're not being destroyed while something is still // playing./*from w w w . java 2s . com*/ if (isPlaying()) { Log.e(LOGTAG_SERVICE, "Service being destroyed while still playing."); } if (mEqualizer != null) { mEqualizer.setEnabled(false); mEqualizer.release(); } mPlayer.release(); mPlayer = null; mAudioManager.abandonAudioFocus(mAudioFocusListener); TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); // make sure there aren't any other messages coming mDelayedStopHandler.removeCallbacksAndMessages(null); mMediaplayerHandler.removeCallbacksAndMessages(null); if (mCursor != null) { mCursor.close(); mCursor = null; } unregisterReceiver(mIntentReceiver); unregisterReceiver(mA2dpReceiver); unregisterReceiver(mExternalAudioDeviceStatusReceiver); if (mUnmountReceiver != null) { unregisterReceiver(mUnmountReceiver); mUnmountReceiver = null; } mWakeLock.release(); mNotificationManager.cancelAll(); removeStickyBroadcast(mPlaybackIntent); super.onDestroy(); }
From source file:com.github.jthuraisamy.yellowusage.ui.MainActivity.java
/** * Run queued tasks provided that mobile data is enabled and connected. If it is not enabled, * prompt the user to enable it so that the device can connect to data. If it is enabled but * connected to WiFi instead, disable WiFi first. Once a data connection is established, the * PhoneStateListener will call this method. *//*from w ww .ja v a 2s .c om*/ private void runTasks() { if (isMobileDataEnabled(connectivityManager)) { Log.i(TAG, "runTasks: Data is enabled."); if (isMobileDataConnected(telephonyManager)) { Log.i(TAG, "runTasks: Data is connected."); // Empty and execute tasks in the task queue. while (!taskQueue.isEmpty()) taskQueue.remove().execute(); } else { Log.i(TAG, "runTasks: Data is disconnected."); if (taskQueue.isEmpty()) return; if (isWifiConnected(wifiManager)) { Log.i(TAG, "runTasks: Disabling WiFi..."); // Start prepare refresh animation in the app bar via onPrepareOptionsMenu(). supportInvalidateOptionsMenu(); // Disable WiFi, and call runTasks() again after data is connected. telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); Toast.makeText(this, R.string.disabling_wifi, Toast.LENGTH_SHORT).show(); wifiManager.setWifiEnabled(false); wifiWasEnabled = true; } } } else { Log.i(TAG, "runTasks: Data is disabled."); Toast.makeText(this, R.string.enable_mobile_data, Toast.LENGTH_LONG).show(); } }
From source file:com.csipsimple.service.SipService.java
/** * Remove registration of broadcasts receiver. *//*from ww w . j av a2 s .co m*/ private void unregisterBroadcasts() { if (deviceStateReceiver != null) { try { Log.d(THIS_FILE, "Stop and unregister device receiver"); deviceStateReceiver.stopMonitoring(); unregisterReceiver(deviceStateReceiver); deviceStateReceiver = null; } catch (IllegalArgumentException e) { // This is the case if already unregistered itself // Python style usage of try ;) : nothing to do here since it could // be a standard case // And in this case nothing has to be done Log.d(THIS_FILE, "Has not to unregister telephony receiver"); } } if (phoneConnectivityReceiver != null) { Log.d(THIS_FILE, "Unregister telephony receiver"); telephonyManager.listen(phoneConnectivityReceiver, PhoneStateListener.LISTEN_NONE); phoneConnectivityReceiver = null; } if (statusObserver != null) { getContentResolver().unregisterContentObserver(statusObserver); statusObserver = null; } }
From source file:com.xperia64.timidityae.MusicService.java
public void stop() { if (Globals.isPlaying == 0) { death = true;// w w w . j a v a 2 s .c o m Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.ta_rec)); new_intent.putExtra(getResources().getString(R.string.ta_cmd), 5); new_intent.putExtra(getResources().getString(R.string.ta_pause), false); sendBroadcast(new_intent); Globals.shouldRestore = false; JNIHandler.stop(); if (fullStop) { TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if (mgr != null) { mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); } Globals.shouldRestore = false; if (wl.isHeld()) wl.release(); foreground = false; fullStop = false; // Fix the widget if (shouldDoWidget) { new_intent = new Intent(this, TimidityAEWidgetProvider.class); new_intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); //new_intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); new_intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.paused", true); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.title", ""); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.onlyart", false); new_intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.death", true); sendBroadcast(new_intent); } else { Globals.nukedWidgets = true; } stopForeground(true); //stopSelf(); } } }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * Stop FemtoCell detection tracking (For CDMA Devices ONLY!) *//* w w w .j a va2 s. c om*/ public void stopTrackingFemto() { if (mPhoneStateListener != null) { tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); trackingFemtocell = false; setNotification(); log.verbose(context.getString(R.string.stopped_tracking_femtocell)); } }