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:de.madvertise.android.sdk.MadvertiseUtil.java
public static String getHashedMacAddress(Context context, HashType hashType) { String mac = null;//ww w .j av a 2s. c om if (MadvertiseUtil.checkPermissionGranted(android.Manifest.permission.ACCESS_WIFI_STATE, context)) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); mac = wm.getConnectionInfo().getMacAddress(); } if (mac == null) { mac = ""; } else { mac = MadvertiseUtil.getHash(mac, hashType); } return mac; }
From source file:at.alladin.rmbt.android.test.RMBTService.java
@Override public void onCreate() { Log.d(DEBUG_TAG, "created"); super.onCreate(); handler = new Handler(); // initialise the locks loopMode = ConfigHelper.isLoopMode(this); // initialise the locks wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "RMBTWifiLock"); wakeLock = ((PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RMBTWakeLock"); // mNetworkStateIntentReceiver = new BroadcastReceiver() { // @Override/* ww w .j ava 2 s. co m*/ // public void onReceive(Context context, Intent intent) { // if // (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) // { // // final boolean connected = ! // intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, // false); // if (! connected) // stopTest(); // } // } // }; // final IntentFilter networkStateChangedFilter = new IntentFilter(); // networkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); // // registerReceiver(mNetworkStateIntentReceiver, // networkStateChangedFilter); }
From source file:org.camlistore.UploadService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mPrefs = new Preferences(getSharedPreferences(Preferences.filename(this.getBaseContext()), 0)); updateBackgroundWatchers();//from ww w .ja v a 2 s .co m startForeground(NOTIFY_ID_FOREGROUND, newNotification()); }
From source file:com.mplayer_remote.ServicePlayAFile.java
/** * Metoda uruchamiana po przekazaniu do usugi dziedziczcej po <code>IntentService</code> wiadomoci <code>Intent</code>, w tym wypadku zawierajcej nazw i ciek do pliku multimedialnego wybranego przez uytkownika. * @see android.app.IntentService#onHandleIntent(android.content.Intent) */// w w w. ja v a2s . c o m @Override protected void onHandleIntent(Intent intent) { Log.v(TAG, "stopExecuteIntents = " + stopExecuteIntents); if (stopExecuteIntents == false) { fileToPlayString = intent.getStringExtra("file_to_play"); Log.v(TAG, "file_to_play przekazane przez intent z FileChoosera: " + fileToPlayString); absolutePathString = intent.getStringExtra("absolute_path"); Log.v(TAG, "absolute_path przekazane przez intent z FileChoosera: " + absolutePathString); showNotyfications(); WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "MyWifiLock"); if (!wifiLock.isHeld()) { wifiLock.acquire(); } if (isfifofileExist() == false) { // isfifofileExist() luck for a true fifo while (ConnectToServer.sendCommandAndWaitForExitStatus("mkfifo fifofile") != 0) { ConnectToServer.sendCommand("rm fifofile"); } } Intent intent_start_RemoteControl = new Intent(getApplicationContext(), RemoteControl.class); intent_start_RemoteControl.putExtra("file_to_play", fileToPlayString); intent_start_RemoteControl.putExtra("absolute_path", absolutePathString); intent_start_RemoteControl.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //intent_start_RemoteControl.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); startActivity(intent_start_RemoteControl); ConnectToServer.sendCommandAndSaveOutputToLockedArrayList( "export DISPLAY=:0.0 && mplayer -fs -slave -quiet -input file=fifofile " + "\"" + fileToPlayString + "\"", mplayerOutputArrayList, mplayerOutputArrayListLock, newMplayerOutputCondition); //RemoteControl.RemoteControlActivityObject.finish(); //ConnectToServer.sendCommand("rm fifofile"); } }
From source file:de.taxilof.UulmLoginAgent.java
/** * fetch the IP of the Device/* w ww . j a v a 2 s.c o m*/ * * @return ip */ private String getIp() { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); String ipAddress = null; if (wifiInfo != null) { long addr = wifiInfo.getIpAddress(); if (addr != 0) { if (addr < 0) addr += 0x100000000L; // handle negative values whe first // octet > 127 ipAddress = String.format("%d.%d.%d.%d", addr & 0xFF, (addr >> 8) & 0xFF, (addr >> 16) & 0xFF, (addr >> 24) & 0xFF); } } return ipAddress; }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the device WiFi MAC//from w ww .j a v a 2s . c o m */ public String getMACAddress() { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wInfo = wifiManager.getConnectionInfo(); mac = wInfo.getMacAddress(); return mac; }
From source file:com.bayapps.android.robophish.playback.LocalPlayback.java
public LocalPlayback(Context context, MusicProvider musicProvider) { this.mContext = context; this.mMusicProvider = musicProvider; this.mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Create the Wifi lock (this does not acquire the lock, this just creates it) this.mWifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "uAmp_lock"); this.mState = PlaybackStateCompat.STATE_NONE; }
From source file:com.jtxdriggers.android.ventriloid.VentriloidService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { int id = intent.getExtras().getInt("id"); ServerAdapter db = new ServerAdapter(this); server = db.getServer(id);/*from ww w . j av a2 s .c om*/ items = new ItemData(this); queue.clear(); volumePrefs = getSharedPreferences("VOLUMES" + server.getId(), Context.MODE_PRIVATE); passwordPrefs = getSharedPreferences("PASSWORDS" + server.getId(), Context.MODE_PRIVATE); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VentriloidWakeLock"); wakeLock.acquire(); wifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "VentriloidWifiLock"); wifiLock.acquire(); disconnect = true; r = new Runnable() { public void run() { timeout = true; handler.postDelayed(new Runnable() { @Override public void run() { if (timeout) { VentriloInterface.logout(); sendBroadcast(new Intent(Main.SERVICE_RECEIVER).putExtra("type", (short) VentriloEvents.V3_EVENT_LOGIN_FAIL)); Toast.makeText(getApplicationContext(), "Connection timed out.", Toast.LENGTH_SHORT) .show(); reconnectTimer = 10; handler.post(r); } } }, 9500); if (VentriloInterface.login(server.getHostname() + ":" + server.getPort(), server.getUsername(), server.getPassword(), server.getPhonetic())) { new Thread(new Runnable() { public void run() { while (VentriloInterface.recv()) ; } }).start(); } else { handler.post(new Runnable() { @Override public void run() { VentriloEventData data = new VentriloEventData(); VentriloInterface.error(data); sendBroadcast(new Intent(Main.SERVICE_RECEIVER).putExtra("type", (short) VentriloEvents.V3_EVENT_LOGIN_FAIL)); Toast.makeText(getApplicationContext(), bytesToString(data.error.message), Toast.LENGTH_SHORT).show(); } }); } timeout = false; } }; handler.post(r); return Service.START_NOT_STICKY; }
From source file:csic.ceab.movelab.beepath.FixGet.java
/** * Creates a new FixGet service instance.<br> * Begins location recording process. Creates a location manager and two * location listeners. Begins requesting updates from both the GPS and * network services, with one location listener receiving updates from one * provider.//from w w w .j av a 2 s . c o m * <p> * If either provider is unavailable, no updates will ever be returned to * the corresponding location listener. */ @Override public void onCreate() { Context context = getApplicationContext(); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); wifiLock = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).createWifiLock( WifiManager.WIFI_MODE_SCAN_ONLY, context.getResources().getString(R.string.internal_message_id) + "WifiLock"); wakeLock = ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).newWakeLock( PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, context.getResources().getString(R.string.internal_message_id) + "ScreenDimWakeLock"); minDist = Util.getMinDist(context); }
From source file:com.iiitd.networking.UDPMessenger.java
public void startMessageReceiver() { Runnable receiver = new Runnable() { @Override/*ww w . j a v a 2s . c o m*/ public void run() { WifiManager wim = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wim != null) { MulticastLock mcLock = wim.createMulticastLock(TAG); mcLock.acquire(); } byte[] buffer = new byte[BUFFER_SIZE]; DatagramPacket rPacket = new DatagramPacket(buffer, buffer.length); MulticastSocket rSocket; try { rSocket = new MulticastSocket(MULTICAST_PORT); } catch (IOException e) { Log.d(DEBUG_TAG, "Impossible to create a new MulticastSocket on port " + MULTICAST_PORT); e.printStackTrace(); return; } while (receiveMessages) { try { rSocket.receive(rPacket); } catch (IOException e1) { Log.d(DEBUG_TAG, "There was a problem receiving the incoming message."); e1.printStackTrace(); continue; } if (!receiveMessages) break; byte data[] = rPacket.getData(); int i; for (i = 0; i < data.length; i++) { if (data[i] == '\0') break; } String messageText; try { messageText = new String(data, 0, i, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.d(DEBUG_TAG, "UTF-8 encoding is not supported. Can't receive the incoming message."); e.printStackTrace(); continue; } try { incomingMessage = new Message(messageText, rPacket.getAddress()); } catch (IllegalArgumentException ex) { Log.d(DEBUG_TAG, "There was a problem processing the message: " + messageText); ex.printStackTrace(); continue; } incomingMessageHandler.post(getIncomingMessageAnalyseRunnable()); } } }; receiveMessages = true; if (receiverThread == null) receiverThread = new Thread(receiver); if (!receiverThread.isAlive()) receiverThread.start(); }