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.SecUpwN.AIMSICD.service.AimsicdService.java
/** * Updates Neighbouring Cell details//from w w w. j av a2 s . c o m */ public List<Cell> updateNeighbouringCells() { List<Cell> neighboringCells = new ArrayList<>(); List<NeighboringCellInfo> neighboringCellInfo; neighboringCellInfo = tm.getNeighboringCellInfo(); if (neighboringCellInfo.size() == 0) { // try to poll the neighboring cells for a few seconds final LinkedBlockingQueue<NeighboringCellInfo> neighboringCellBlockingQueue = new LinkedBlockingQueue<>( 100); final PhoneStateListener listener = new PhoneStateListener() { private void handle() { List<NeighboringCellInfo> neighboringCellInfo; neighboringCellInfo = tm.getNeighboringCellInfo(); if (neighboringCellInfo.size() == 0) { return; } Log.i(TAG, "neighbouringCellInfo empty - event based polling succeeded!"); tm.listen(this, PhoneStateListener.LISTEN_NONE); neighboringCellBlockingQueue.addAll(neighboringCellInfo); } @Override public void onServiceStateChanged(ServiceState serviceState) { handle(); } @Override public void onDataConnectionStateChanged(int state) { handle(); } @Override public void onDataConnectionStateChanged(int state, int networkType) { handle(); } @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { handle(); } @Override public void onCellInfoChanged(List<CellInfo> cellInfo) { handle(); } }; Log.i(TAG, "neighbouringCellInfo empty - start polling"); //LISTEN_CELL_INFO added in API 17 if (Build.VERSION.SDK_INT > 16) { tm.listen(listener, PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } else { tm.listen(listener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } for (int i = 0; i < 10 && neighboringCellInfo.size() == 0; i++) { try { Log.i(TAG, "neighbouringCellInfo empty - try " + i); NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS); if (info == null) { neighboringCellInfo = tm.getNeighboringCellInfo(); if (neighboringCellInfo.size() > 0) { Log.i(TAG, "neighbouringCellInfo empty - try " + i + " succeeded time based"); break; } else { continue; } } ArrayList<NeighboringCellInfo> cellInfoList = new ArrayList<NeighboringCellInfo>( neighboringCellBlockingQueue.size() + 1); while (info != null) { cellInfoList.add(info); info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS); } neighboringCellInfo = cellInfoList; } catch (InterruptedException e) { // normal } } } Log.i(TAG, "neighbouringCellInfo Size - " + neighboringCellInfo.size()); for (NeighboringCellInfo neighbourCell : neighboringCellInfo) { Log.i(TAG, "neighbouringCellInfo - CID:" + neighbourCell.getCid() + " LAC:" + neighbourCell.getLac() + " RSSI:" + neighbourCell.getRssi() + " PSC:" + neighbourCell.getPsc()); final Cell cell = new Cell(neighbourCell.getCid(), neighbourCell.getLac(), neighbourCell.getRssi(), neighbourCell.getPsc(), neighbourCell.getNetworkType(), false); neighboringCells.add(cell); } return neighboringCells; }
From source file:net.kidlogger.kidlogger.KLService.java
@Override public void onDestroy() { super.onDestroy(); try {//www .java 2s .c o m if (uploadOn && mAlarmManager != null) { mAlarmManager.cancel(mPI); } if (taskOn) { handleTask.removeCallbacks(taskScan); } if (clipOn) { handleClipb.removeCallbacks(clipboardScan); } if (delayNewCallEvent != null) { delayNewCallEvent.cancel(); } if (gpsOn) { locMngr.removeUpdates(locListener); } if (wifiOn && wifiReceiver != null) { unregisterReceiver(wifiReceiver); } if (smsOn && smsObserver != null && smsObserver.inSms != null) { unregisterReceiver(smsObserver.inSms); smsObserver.unregisterObserver(); } if (callOn && callsReceiver != null) { unregisterReceiver(callsReceiver); } if (idleOn && idleReceiver != null) { unregisterReceiver(idleReceiver); } if (urlOn && urlObserver != null) { urlObserver.unregisterObserver(); } if (usbOn && usbReceiver != null) { unregisterReceiver(usbReceiver); } if (powerOn && powerReceiver != null) { unregisterReceiver(powerReceiver); } if (mediaOn && mediaReceiver != null) { unregisterReceiver(mediaReceiver); } if (gsmOn && telManager != null && gsmObserver != null) { telManager.listen(gsmObserver, PhoneStateListener.LISTEN_NONE); } if (airOn && airReceiver != null) { unregisterReceiver(airReceiver); } if (photoOn && photoObserver != null) { photoObserver.unregisterObserver(); } if (mConReceiver != null) unregisterReceiver(mConReceiver); } catch (IllegalArgumentException e) { app.logError(CN + "onDestroy", e.toString()); } saveToPref("fileName", file); saveToPref("uploadedSize", uploadedSize); // Log stop service logServiceState(false); serviceStarted = false; app.mService = null; //Log.i(CN + "onDestroy", "onDestroy"); }
From source file:org.pixmob.freemobile.netstat.MonitorService.java
@Override public void onDestroy() { super.onDestroy(); // Tell the PendingInsert worker thread to stop. try {/*from w ww. j ava2s. c o m*/ pendingInsert.put(STOP_PENDING_CONTENT_MARKER); } catch (InterruptedException e) { Log.e(TAG, "Failed to stop PendingInsert worker thread", e); } // Stop listening to system events. unregisterReceiver(screenMonitor); tm.listen(phoneMonitor, PhoneStateListener.LISTEN_NONE); unregisterReceiver(connectionMonitor); unregisterReceiver(batteryMonitor); unregisterReceiver(shutdownMonitor); tm = null; cm = null; pm = null; // Remove the status bar notification. stopForeground(true); prefs.unregisterOnSharedPreferenceChangeListener(this); prefs = null; if (freeLargeIcon != null) { freeLargeIcon.recycle(); freeLargeIcon = null; } if (orangeLargeIcon != null) { orangeLargeIcon.recycle(); orangeLargeIcon = null; } }
From source file:leoisasmendi.android.com.suricatepodcast.services.MediaPlayerService.java
@Override public void onDestroy() { super.onDestroy(); if (mediaPlayer != null) { stopMedia();/* w w w. j a v a 2s . co m*/ mediaPlayer.release(); } removeAudioFocus(); //Disable the PhoneStateListener if (phoneStateListener != null) { telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); } removeNotification(); //unregister BroadcastReceivers unregisterReceiver(becomingNoisyReceiver); unregisterReceiver(playNewAudio); //clear cached playlist new StorageUtil(getApplicationContext()).clearCachedAudioPlaylist(); mCursor.close(); }
From source file:com.cw.litenote.DrawerActivity.java
@Override protected void onDestroy() { System.out.println("DrawerActivity / onDestroy"); //unregister TelephonyManager listener TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); if (mgr != null) { mgr.listen(UtilAudio.phoneStateListener, PhoneStateListener.LISTEN_NONE); }//from ww w .ja v a 2s .c om // unregister an audio stream receiver if (noisyAudioStreamReceiver != null) { try { unregisterReceiver(noisyAudioStreamReceiver);//??? unregister here? } catch (Exception e) { } noisyAudioStreamReceiver = null; } super.onDestroy(); }
From source file:com.tvs.signaltracker.STService.java
@Override public void onDestroy() { ServiceHandler.removeCallbacks(ReCheck); ServiceHandler.removeCallbacks(ReSendRun); ServiceHandler.removeCallbacks(LightMode); if (CommonHandler.ServiceMode == 2 || CommonHandler.ServiceMode == 4) { Log.i("SignalTracker::STService", "Parando trabalhos"); try {/* w ww.j a v a 2 s .c o m*/ if (mlocManager != null) { mlocManager.removeGpsStatusListener(GPSs); mlocManager.removeUpdates(GPSLocListener); mlocManager.removeUpdates(NetLocListener); } if (Tel != null) Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE); } catch (Exception e) { } ; MyListener = null; Tel = null; mlocManager = null; GPSs = null; GPSLocListener = null; NetLocListener = null; CommonHandler.GPSFix = false; CommonHandler.NumSattelites = 0; CommonHandler.NumConSattelites = 0; try { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nMgr = (NotificationManager) this.getSystemService(ns); nMgr.cancel(NOTIFICATION); } catch (Exception e) { } } Toast.makeText(getApplicationContext(), getResources().getString(R.string.stservicestopped), Toast.LENGTH_LONG).show(); if (!CommonHandler.KillService) { Intent myIntent = new Intent(STService.this, STService.class); PendingIntent pendingIntent = PendingIntent.getService(STService.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 2); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); } CommonHandler.KillService = false; LocalRunning = false; Opened = false; }
From source file:org.tomahawk.tomahawk_android.services.PlaybackService.java
@Override public void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); pause(true);//from ww w . j a va2 s. c om releaseAllPlayers(); if (mWakeLock.isHeld()) { mWakeLock.release(); } mWakeLock = null; TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneCallListener, PhoneStateListener.LISTEN_NONE); mPhoneCallListener = null; mKillTimerHandler.removeCallbacksAndMessages(null); mKillTimerHandler = null; Log.d(TAG, "PlaybackService has been destroyed"); }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
@Override protected void onPause() { super.onPause(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.unregisterOnSharedPreferenceChangeListener(this); unregisterReceiver(interactiveStateReceiver); unregisterReceiver(connectivityChangedReceiver); if (phone_state) { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); phone_state = false;/*from www . jav a 2 s . c o m*/ } }
From source file:com.secupwn.aimsicd.service.CellTracker.java
private void handlePhoneStateChange() { List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo(); if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) { return;//from w ww. j ava2s .c o m } log.info("NeighboringCellInfo empty - event based polling succeeded!"); tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_NONE); if (neighboringCellInfo == null) { neighboringCellInfo = new ArrayList<>(); } neighboringCellBlockingQueue.addAll(neighboringCellInfo); }
From source file:org.mariotaku.harmony.MusicPlaybackService.java
@Override public void onDestroy() { // Check that we're not being destroyed while something is still // playing.// w w w .j a va 2 s . c om if (isPlaying()) { Log.e(LOGTAG_SERVICE, "Service being destroyed while still playing."); } mPlayer.release(); mPlayer = null; mAudioManager.abandonAudioFocus(mAudioFocusListener); final TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); // make sure there aren't any other messages coming mDelayedStopHandler.removeCallbacksAndMessages(null); mMediaplayerHandler.removeCallbacksAndMessages(null); mTrackInfo = null; unregisterReceiver(mIntentReceiver); unregisterReceiver(mA2dpReceiver); unregisterReceiver(mExternalAudioDeviceStatusReceiver); if (mUnmountReceiver != null) { unregisterReceiver(mUnmountReceiver); mUnmountReceiver = null; } mWakeLock.release(); mNotificationManager.cancelAll(); super.onDestroy(); }