List of usage examples for android.content Context WIFI_SERVICE
String WIFI_SERVICE
To view the source code for android.content Context WIFI_SERVICE.
Click Source Link
From source file:ch.bfh.instacircle.NetworkActiveActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_network_active); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*from www .ja v a 2 s . c o m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Handle the change of the Wifi configuration wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); adhoc = new AdhocWifiManager(wifi); wifiapmanager = new WifiAPManager(); registerReceiver(wifiReceiver, new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION)); // Is NFC available on this device? nfcAvailable = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC); // only set up the NFC stuff if NFC is also available if (nfcAvailable) { nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter.isEnabled()) { // Setting up a pending intent that is invoked when an NFC tag // is tapped on the back pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); nfcIntentFilter = new IntentFilter(); nfcIntentFilter.addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); nfcIntentFilter.addAction(NfcAdapter.ACTION_TAG_DISCOVERED); intentFiltersArray = new IntentFilter[] { nfcIntentFilter }; } else { nfcAvailable = false; } } }
From source file:com.yoval.community.chatapp.DistanceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_distance); displayLocationSettingsRequest(getApplicationContext()); if (googleServicesAvalaible()) { //Toast.makeText(this, "Perfect", Toast.LENGTH_LONG).show(); initMap();//from w w w .ja v a2s. c om } else { Toast.makeText(this, "Play services problem", Toast.LENGTH_LONG).show(); } //Check for WIfi services enabled WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (!wifi.isWifiEnabled()) { showWifiRequest(); } CustomizedLocationListener locationListener = new CustomizedLocationListener(getApplicationContext()); locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); if (ContextCompat.checkSelfPermission(this, Manifest.permission.MAPS_RECEIVE) != PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5 * 60 * 1000, 10, locationListener); } if (FirebaseAuth.getInstance().getCurrentUser() == null) { // Start sign in/sign up activity startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().build(), SIGN_IN_REQUEST_CODE); } else { // User is already signed in. Therefore, display // a welcome Toast Toast.makeText(this, R.string.Bienvenue + " " + FirebaseAuth.getInstance().getCurrentUser().getDisplayName(), Toast.LENGTH_LONG).show(); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarDistance); setSupportActionBar(toolbar); SeekBar distanceBar = (SeekBar) findViewById(R.id.seekBarDistance); // make seekbar object distanceBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub TextView textViewDistance = (TextView) findViewById(R.id.textViewDistance); textViewDistance.setText(progress + " Km"); radius = progress; SaveUserInformations(radius); updateZoomMap(); } }); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.distNext); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { goToDetailView(); } }); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
From source file:nuclei.media.playback.FallbackPlayback.java
public FallbackPlayback(MediaService service) { mService = service;//from w w w. j a va 2 s . c om this.mAudioManager = (AudioManager) mService.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) mService.getApplicationContext().getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "uAmp_lock"); this.mState = PlaybackStateCompat.STATE_NONE; }
From source file:com.compal.wifitest.WifiTestCase.java
@Override protected void setUp() throws Exception { super.setUp(); loadConfig();/*w w w . j av a2 s .c o m*/ mWifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); /*if null put result*/ if (mWifiManager == null) { mLog = "WifiManager is null"; } }
From source file:android_network.hetnet.vpn_service.Util.java
public static String getWifiSSID(Context context) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); String ssid = (wm == null ? null : wm.getConnectionInfo().getSSID()); return (ssid == null ? "NULL" : ssid); }
From source file:ch.ethz.coss.nervousnet.vm.sensors.ConnectivitySensor.java
public void runConnectivitySensor() { Log.d(LOG_TAG, "Inside runConnectivitySensor"); if (Build.VERSION.SDK_INT >= 23 && ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { return;// www .j ava 2 s .c o m } ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); int networkType = -1; boolean isRoaming = false; if (isConnected) { networkType = activeNetwork.getType(); isRoaming = activeNetwork.isRoaming(); } String wifiHashId = ""; int wifiStrength = Integer.MIN_VALUE; if (networkType == ConnectivityManager.TYPE_WIFI) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); StringBuilder wifiInfoBuilder = new StringBuilder(); wifiInfoBuilder.append(wi.getBSSID()); wifiInfoBuilder.append(wi.getSSID()); try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.update(wifiInfoBuilder.toString().getBytes()); wifiHashId = new String(messageDigest.digest()); } catch (NoSuchAlgorithmException e) { } wifiStrength = wi.getRssi(); } byte[] cdmaHashId = new byte[32]; byte[] lteHashId = new byte[32]; byte[] gsmHashId = new byte[32]; byte[] wcdmaHashId = new byte[32]; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); List<CellInfo> cis = tm.getAllCellInfo(); if (cis != null) { // New method for (CellInfo ci : cis) { if (ci.isRegistered()) { if (ci instanceof CellInfoCdma) { CellInfoCdma cic = (CellInfoCdma) ci; cdmaHashId = generateMobileDigestId(cic.getCellIdentity().getSystemId(), cic.getCellIdentity().getNetworkId(), cic.getCellIdentity().getBasestationId()); } if (ci instanceof CellInfoGsm) { CellInfoGsm cic = (CellInfoGsm) ci; gsmHashId = generateMobileDigestId(cic.getCellIdentity().getMcc(), cic.getCellIdentity().getMnc(), cic.getCellIdentity().getCid()); } if (ci instanceof CellInfoLte) { CellInfoLte cic = (CellInfoLte) ci; lteHashId = generateMobileDigestId(cic.getCellIdentity().getMcc(), cic.getCellIdentity().getMnc(), cic.getCellIdentity().getCi()); } if (ci instanceof CellInfoWcdma) { CellInfoWcdma cic = (CellInfoWcdma) ci; wcdmaHashId = generateMobileDigestId(cic.getCellIdentity().getMcc(), cic.getCellIdentity().getMnc(), cic.getCellIdentity().getCid()); } } } } else { // Legacy method CellLocation cl = tm.getCellLocation(); if (cl instanceof CdmaCellLocation) { CdmaCellLocation cic = (CdmaCellLocation) cl; cdmaHashId = generateMobileDigestId(cic.getSystemId(), cic.getNetworkId(), cic.getBaseStationId()); } if (cl instanceof GsmCellLocation) { GsmCellLocation cic = (GsmCellLocation) cl; gsmHashId = generateMobileDigestId(cic.getLac(), 0, cic.getCid()); } } StringBuilder mobileHashBuilder = new StringBuilder(); mobileHashBuilder.append(new String(cdmaHashId)); mobileHashBuilder.append(new String(lteHashId)); mobileHashBuilder.append(new String(gsmHashId)); mobileHashBuilder.append(new String(wcdmaHashId)); dataReady(new ConnectivityReading(System.currentTimeMillis(), isConnected, networkType, isRoaming, wifiHashId, wifiStrength, mobileHashBuilder.toString())); }
From source file:com.laer.easycast.VideoPane.java
public void videoRaw(Bitmap image, String transition) { Log.i("photoraw", "photoraw called"); headers.put("X-Apple-Transition", transition); image.compress(Bitmap.CompressFormat.JPEG, 100, wr); MainActivity obj = (MainActivity) getActivity(); WifiManager wifi = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); if (obj.URL != null) { new VideoAirplay().execute(); } else if (obj.URL == null || wifi.isWifiEnabled() != true) { WiFiOptions();//from w ww .j av a2s . c o m if (obj.URL == null) { Toast.makeText(getActivity(), "No compatible devices found", Toast.LENGTH_SHORT).show(); } } }
From source file:com.zuluindia.watchpresenter.MonitorVolumeKeyPress.java
private void startMonitoring() { wifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "WatchPresenterLock"); wifiLock.acquire();/*from ww w.j ava 2 s . com*/ objPlayer.start(); registerReceiver(volumeKeysReceiver, new IntentFilter(ACTION_VOLUME_KEY_PRESS)); Log.d(LOGCAT, "Media Player started!"); if (objPlayer.isLooping() != true) { Log.d(LOGCAT, "Problem in Playing Audio"); } scheduleMaintenance(); }
From source file:org.openremote.android.console.net.ORNetworkCheck.java
/** * Detects the current WiFi status./*from w ww .ja v a2 s. co m*/ * * @param ctx global Android application context * * @return true if WiFi is available, false otherwise */ private static boolean canReachWifiNetwork(Context ctx) { WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); ConnectivityManager connectivityManager = (ConnectivityManager) ctx .getSystemService(Context.CONNECTIVITY_SERVICE); if (!wifiManager.isWifiEnabled() || wifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) { Log.i(LOG_CATEGORY, "WiFi not enabled or WiFi network not detected."); return false; } NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (!wifiNetworkInfo.isAvailable()) { Log.i(LOG_CATEGORY, "Wifi network detected but wasn't available."); return false; } else { return true; } }