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:org.deviceconnect.android.message.DevicePluginContext.java
/** * .//from ww w. j a v a 2 s . com * @param context */ public DevicePluginContext(final Context context) { if (context == null) { throw new IllegalArgumentException("context is null."); } mContext = context; // ??? EventManager.INSTANCE.setController(createEventCacheController()); // LocalOAuth?? mLocalOAuth2Main = new LocalOAuth2Main(context); try { // SPEC?? mPluginSpec = DConnectProfileHelper.loadPluginSpec(context, createSupportedProfiles()); } catch (Exception e) { if (BuildConfig.DEBUG) { mLogger.warning("Failed to load a profile spec."); } } // ??? mKeyStoreMgr = new EndPointKeyStoreManager(context, getKeyStoreFileName(), getCertificateAlias()); if (usesAutoCertificateRequest()) { requestAndNotifyKeyStore(); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(mWiFiBroadcastReceiver, filter); } // ? mServiceProvider = new DConnectServiceManager(); mServiceProvider.setContext(context); mServiceProvider.setPluginContext(this); mServiceProvider.setPluginSpec(mPluginSpec); // addProfile(new AuthorizationProfile(this, mLocalOAuth2Main)); addProfile(new ServiceDiscoveryProfile(mServiceProvider)); addProfile(getSystemProfile()); }
From source file:org.simlar.SimlarService.java
@Override public void onCreate() { Log.i(LOGTAG, "started on device: " + Build.DEVICE); FileHelper.init(this); mVibratorThread = new VibratorThread(this.getApplicationContext()); mRingtoneThread = new RingtoneThread(this.getApplicationContext()); mWakeLock = ((PowerManager) this.getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "SimlarWakeLock"); mWifiLock = ((WifiManager) this.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "SimlarWifiLock"); startForeground(NOTIFICATION_ID, createNotification(SimlarStatus.OFFLINE)); mLinphoneThread = new LinphoneThread(this, this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mNetworkChangeReceiver, intentFilter); startKeepAwake();//from w ww.j a va2 s .c o m mHandler.post(new Runnable() { @Override public void run() { initializeCredentials(); } }); }
From source file:io.github.protino.codewatch.ui.NavigationDrawerActivity.java
@Override protected void onResume() { super.onResume(); attachValueEventListener();/* ww w . j a v a2 s. c o m*/ registerReceiver(broadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferService.java
@Override @SuppressWarnings("checkstyle:hiddenfield") public int onStartCommand(Intent intent, int flags, int startId) { this.startId = startId; if (intent == null) { return START_REDELIVER_INTENT; }/*from w w w .j a v a 2s . co m*/ final String keyForS3Client = intent.getStringExtra(INTENT_BUNDLE_S3_REFERENCE_KEY); s3 = S3ClientReference.get(keyForS3Client); if (s3 == null) { LOGGER.warn("TransferService can't get s3 client, and it will stop."); stopSelf(startId); return START_NOT_STICKY; } updateHandler.sendMessage(updateHandler.obtainMessage(MSG_EXEC, intent)); if (isFirst) { registerReceiver(networkInfoReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); isFirst = false; } /* * The service will not restart if it's killed by system. */ return START_NOT_STICKY; }
From source file:org.hubiquitus.hapi.transport.HTransportManager.java
private void registerReceivers() { MyApplication.getAppContext().registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:org.site_monitor.activity.MainActivity.java
@Override protected void onResume() { super.onResume(); if (loadDataFromDb) { loadSiteSettingsBusinesses();/*w ww . j a v a 2s .c om*/ } else { loadDataFromDb = false; } scheduleTimer(); onNetworkStateChanged(ConnectivityUtil.isConnected(this)); LocalBroadcastManager.getInstance(this).registerReceiver(alarmBroadcastReceiver, new IntentFilter(AlarmUtil.ACTION_NEXT_ALARM_SET)); LocalBroadcastManager.getInstance(this).registerReceiver(networkBroadcastReceiver, new IntentFilter(NetworkService.ACTION_SITE_START_REFRESH)); LocalBroadcastManager.getInstance(this).registerReceiver(networkBroadcastReceiver, new IntentFilter(NetworkService.ACTION_SITE_END_REFRESH)); LocalBroadcastManager.getInstance(this).registerReceiver(networkBroadcastReceiver, new IntentFilter(FavIconService.ACTION_FAVICON_UPDATED)); registerReceiver(networkBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:edu.mit.mobile.android.locast.data.Sync.java
@Override public void onCreate() { super.onCreate(); nc = NetworkClient.getInstance(this); cr = getApplicationContext().getContentResolver(); registerReceiver(networkStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:cat.terrones.devops.radiofx.ui.MediaBrowserFragment.java
@Override public void onStart() { super.onStart(); // fetch browsing information to fill the listview: MediaBrowserCompat mediaBrowser = mMediaFragmentListener.getMediaBrowser(); Log.d(TAG, "fragment.onStart, mediaId=" + mMediaId + " onConnected=" + mediaBrowser.isConnected()); if (mediaBrowser.isConnected()) { onConnected();/* w w w .ja v a2 s . com*/ } // Registers BroadcastReceiver to track network connection changes. this.getActivity().registerReceiver(mConnectivityChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentActivityPointer = this; setContentView(R.layout.main);/*from w w w. j a v a 2s . co m*/ m_app = (TodoApplication) getApplication(); m_app.m_prefs.registerOnSharedPreferenceChangeListener(this); this.taskBag = m_app.getTaskBag(); m_adapter = new TaskAdapter(this, R.layout.list_item, taskBag.getTasks(), getLayoutInflater()); // listen to the ACTION_LOGOUT intent, if heard display LoginScreen // and finish() current activity IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.INTENT_ACTION_ARCHIVE); intentFilter.addAction(Constants.INTENT_SYNC_CONFLICT); intentFilter.addAction(Constants.INTENT_ACTION_LOGOUT); intentFilter.addAction(Constants.INTENT_UPDATE_UI); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); m_broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_ARCHIVE)) { // archive // refresh screen to remove completed tasks // push to remote //archiveTasks(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_LOGOUT)) { taskBag.clear(); m_app.broadcastWidgetUpdate(); // Intent i = new Intent(context, LoginScreen.class); // startActivity(i); // finish(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_UPDATE_UI)) { updateSyncUI(intent.getBooleanExtra("redrawList", false)); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_SYNC_CONFLICT)) { handleSyncConflict(); } else if (intent.getAction().equalsIgnoreCase(ConnectivityManager.CONNECTIVITY_ACTION)) { handleConnectivityChange(context); } // Taskbag might have changed, update drawer adapter // to reflect new/removed contexts and projects updateNavigationDrawer(); } }; registerReceiver(m_broadcastReceiver, intentFilter); setListAdapter(this.m_adapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); // Setup Navigation drawer m_drawerList = (ListView) findViewById(R.id.left_drawer); m_drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Set the adapter for the list view updateNavigationDrawer(); SwipeDismissList.OnDismissCallback callback = new SwipeDismissList.OnDismissCallback() { // Gets called whenever the user deletes an item. public SwipeDismissList.Undoable onDismiss(AbsListView listView, final int position) { m_swipeList.setEnabled(false); final Task task = m_adapter.getItem(position); m_adapter.remove(task); ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); final boolean wasComplete = task.isCompleted(); final String popupTitle = listView.getResources() .getString(wasComplete ? R.string.swipe_action_unComplete : R.string.swipe_action_complete); if (wasComplete) { undoCompleteTasks(tasks, false); } else { completeTasks(tasks, false); } // Return an Undoable implementing every method return new SwipeDismissList.Undoable() { // Method is called when user undoes this deletion public void undo() { // Reinsert item to list ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); if (wasComplete) { completeTasks(tasks, false); } else { undoCompleteTasks(tasks, false); } } @Override public String getTitle() { return popupTitle; } }; } }; m_swipeList = new SwipeDismissList(lv, callback, SwipeDismissList.UndoMode.SINGLE_UNDO); m_swipeList.setPopupYOffset(56); m_swipeList.setAutoHideDelay(250); m_swipeList.setSwipeLayout(R.id.swipe_view); m_pullToRefreshAttacher = PullToRefreshAttacher.get(this); DefaultHeaderTransformer ht = (DefaultHeaderTransformer) m_pullToRefreshAttacher.getHeaderTransformer(); ht.setPullText(getString(R.string.pull_to_refresh)); ht.setRefreshingText(getString(R.string.syncing)); m_pullToRefreshAttacher.addRefreshableView(lv, this); // Delegate OnTouch calls to both libraries that want to receive them // Don't forward swipes when swiping on the left lv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { // Don't listen to gestures on the left area of the list // to prevent interference with the DrawerLayout ViewConfiguration vc = ViewConfiguration.get(view.getContext()); int deadZoneX = vc.getScaledTouchSlop(); if (motionEvent.getX() < deadZoneX) { return false; } m_pullToRefreshAttacher.onTouch(view, motionEvent); // Only listen to item swipes if we are not scrolling the // listview if (!mListScrolling && m_swipeList.onTouch(view, motionEvent)) { return false; } return false; } }); // We must set the scrollListener after the onTouchListener, // otherwise it will not fire lv.setOnScrollListener(this); initializeTasks(false); // Show search results Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { m_app.m_search = intent.getStringExtra(SearchManager.QUERY); Log.v(TAG, "Searched for " + m_app.m_search); m_app.storeFilters(); setFilteredTasks(false); } }
From source file:com.torrenttunes.android.ui.MediaBrowserFragment.java
@Override public void onStart() { super.onStart(); // fetch browsing information to fill the listview: MediaBrowserCompat mediaBrowser = mMediaFragmentListener.getMediaBrowser(); LogHelper.d(TAG, "fragment.onStart, mediaId=", mMediaId, " onConnected=" + mediaBrowser.isConnected()); if (mediaBrowser != null && mediaBrowser.isConnected()) { onConnected();/*from w ww .j a v a2 s .c o m*/ } // Registers BroadcastReceiver to track network connection changes. this.getActivity().registerReceiver(mConnectivityChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }