List of usage examples for android.net ConnectivityManager CONNECTIVITY_ACTION
String CONNECTIVITY_ACTION
To view the source code for android.net ConnectivityManager CONNECTIVITY_ACTION.
Click Source Link
From source file:com.seadee.degree.service.NetworkStateReceiver.java
public void regNetworkReciever(Context context) { this.context = context; instance = this; IntentFilter mFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(this, mFilter); }
From source file:org.videolan.vlc.gui.tv.browser.BaseTvActivity.java
@Override protected void onResume() { super.onResume(); mIsVisible = true;//from www . j av a 2 s . c o m //Handle network connection state IntentFilter networkFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); IntentFilter storageFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED); storageFilter.addAction(Intent.ACTION_MEDIA_REMOVED); storageFilter.addAction(Intent.ACTION_MEDIA_EJECT); storageFilter.addDataScheme("file"); IntentFilter parsingServiceFilter = new IntentFilter(MediaParsingService.ACTION_SERVICE_ENDED); parsingServiceFilter.addAction(MediaParsingService.ACTION_SERVICE_STARTED); mRegistering = true; LocalBroadcastManager.getInstance(this).registerReceiver(mParsingServiceReceiver, parsingServiceFilter); registerReceiver(mExternalDevicesReceiver, storageFilter); registerReceiver(mExternalDevicesReceiver, networkFilter); }
From source file:com.coinomi.wallet.ui.ExchangeRateLoader.java
@Override protected void onStartLoading() { super.onStartLoading(); refreshUri(config.getExchangeCurrencyCode()); config.registerOnSharedPreferenceChangeListener(this); final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_TIME_TICK); context.registerReceiver(broadcastReceiver, intentFilter); forceLoad();/* ww w . ja v a 2 s . co m*/ }
From source file:com.cerema.cloud2.files.InstantUploadBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log_OC.d(TAG, "Received: " + intent.getAction()); if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) { handleConnectivityAction(context, intent); } else if (intent.getAction().equals(NEW_PHOTO_ACTION_UNOFFICIAL)) { handleNewPictureAction(context, intent); Log_OC.d(TAG, "UNOFFICIAL processed: com.android.camera.NEW_PICTURE"); } else if (intent.getAction().equals(NEW_PHOTO_ACTION)) { handleNewPictureAction(context, intent); Log_OC.d(TAG, "OFFICIAL processed: android.hardware.action.NEW_PICTURE"); } else if (intent.getAction().equals(NEW_VIDEO_ACTION)) { Log_OC.d(TAG, "OFFICIAL processed: android.hardware.action.NEW_VIDEO"); handleNewVideoAction(context, intent); } else {// w w w. j ava2 s.co m Log_OC.e(TAG, "Incorrect intent sent: " + intent.getAction()); } }
From source file:com.drinviewer.droiddrinviewer.DrinViewerBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); if (networkInfo.isConnected()) { /**/*from w w w . j a va2s .c om*/ * WiFi is connected, get its broadcast * address and start the discovery process * repeated at a fixed time interval */ wifiBroadcastAddress = getWiFiBroadcastAddress(context); startAlarmRepeater(context); } else { wifiBroadcastAddress = null; } } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI && !networkInfo.isConnected()) { /** * WiFi is disconnected, stop the discovery * process repeating, it would be a waste of resources */ wifiBroadcastAddress = null; stopAlarmRepeater(context); } } else if (intent.getAction().equals(context.getResources().getString(R.string.broadcast_startdiscovery)) || intent.getAction() .equals(context.getResources().getString(R.string.broadcast_cleanhostcollection))) { boolean startService = true; /** * Calls the DiscoverServerService asking to do a discovery * or a clean host collection by simply forwarding the received action */ Intent service = new Intent(context, DiscoverServerService.class); service.setAction(intent.getAction()); if (intent.getAction().equals(context.getResources().getString(R.string.broadcast_startdiscovery))) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); wifiBroadcastAddress = (mWifi.isConnected()) ? getWiFiBroadcastAddress(context) : null; startService = wifiBroadcastAddress != null; service.putExtra("wifiBroadcastAddress", wifiBroadcastAddress); } if (startService) startWakefulService(context, service); if (intent.getBooleanExtra("stopservice", false)) { context.stopService(service); } } else if (intent.getAction() .equals(context.getResources().getString(R.string.broadcast_startalarmrepeater))) { /** * start the alarm repeater only if WiFi is connected already * used by ServerListFragment.onServiceConnected method to start the discovery * if the application is launched being already connected to a WiFi network */ ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mWifi.isConnected()) { // if we're called from the activity, try to get a broadcast address if (intent.getBooleanExtra("forcegetbroadcast", false)) wifiBroadcastAddress = getWiFiBroadcastAddress(context); startAlarmRepeater(context); } else { wifiBroadcastAddress = null; } } else if (intent.getAction() .equals(context.getResources().getString(R.string.broadcast_stopalarmrepeater))) { /** * stop the alarm repeater. period. * used by DrinViewerApplication.onTerminate method */ wifiBroadcastAddress = null; stopAlarmRepeater(context); } }
From source file:com.github.ignition.support.http.IgnitedHttpClient.java
public IgnitedHttpClient(Context context) { appContext = context.getApplicationContext(); setupHttpClient();//from w ww .j a va2 s.c om appContext.registerReceiver(new ConnectionChangedBroadcastReceiver(this), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:org.smap.smapTask.android.receivers.NetworkReceiver.java
@Override public void onReceive(Context context, Intent intent) { // make sure sd card is ready, if not don't try to send if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return;//from w ww .j a v a 2 s .co m } String action = intent.getAction(); ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo currentNetworkInfo = manager.getActiveNetworkInfo(); if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { if (currentNetworkInfo != null && currentNetworkInfo.getState() == NetworkInfo.State.CONNECTED) { if (interfaceIsEnabled(context, currentNetworkInfo)) { //uploadForms(context); refreshTasks(context); } } } else if (action.equals("org.odk.collect.android.FormSaved")) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni == null || !ni.isConnected()) { // not connected, do nothing } else { if (interfaceIsEnabled(context, ni)) { refreshTasks(context); } } } }
From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.FixturesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fixtures_layout, container, false); ButterKnife.inject(this, view); buildGoogleApiClient();// w ww . j a v a 2 s .c o m //Registering events to detect radio changes final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { updateBluetoothStatusDisplay(); } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { updateWifiStatusDisplay(); } else if (action.equals(LocationManager.PROVIDERS_CHANGED_ACTION)) { updateGPSStatusDisplay(); } else if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) { updateNFCStatusDisplay(); } } }; IntentFilter filter = new IntentFilter(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { filter.addAction(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED); } filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(LocationManager.PROVIDERS_CHANGED_ACTION); updateWifiStatusDisplay(); updateBluetoothStatusDisplay(); updateGPSStatusDisplay(); updateNFCStatusDisplay(); getActivity().registerReceiver(receiver, filter); return view; }
From source file:org.deviceconnect.android.manager.DConnectWebService.java
/** * Web??.//from w w w . j av a 2 s . c om */ private synchronized void startWebServer() { if (mWebServer == null) { mSettings.load(this); DConnectServerConfig.Builder builder = new DConnectServerConfig.Builder(); builder.port(mSettings.getWebPort()).documentRootPath(mSettings.getDocumentRootPath()); if (BuildConfig.DEBUG) { mLogger.info("Web Server was Started."); mLogger.info("Host: " + mSettings.getHost()); mLogger.info("Port: " + mSettings.getWebPort()); mLogger.info("Document Root: " + mSettings.getDocumentRootPath()); } mWebServer = new DConnectServerNanoHttpd(builder.build(), this); mWebServer.start(); showNotification(); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mWiFiReceiver, filter); } }
From source file:org.gateshipone.odyssey.artworkdatabase.BulkDownloadService.java
/** * Called when the service is created because it is requested by an activity *//* w w w. j a va2 s .c om*/ @Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mConnectionStateChangeReceiver = new ConnectionStateReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mConnectionStateChangeReceiver, filter); }