Search in sources :

Example 36 with WifiManager

use of android.net.wifi.WifiManager in project FastDev4Android by jiangqqlmj.

the class StrUtils method getIpAddress.

// 获取用户的IPd
public static int getIpAddress() {
    int ipAddress = 0;
    WifiManager wifiManager = (WifiManager) FDApplication.getInstance().getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo == null || wifiInfo.equals("")) {
        return ipAddress;
    } else {
        ipAddress = wifiInfo.getIpAddress();
    }
    return ipAddress;
}
Also used : WifiManager(android.net.wifi.WifiManager) SuppressLint(android.annotation.SuppressLint) WifiInfo(android.net.wifi.WifiInfo)

Example 37 with WifiManager

use of android.net.wifi.WifiManager in project PushSms by koush.

the class Helper method acquireTemporaryWakelocks.

public static void acquireTemporaryWakelocks(Context context, long timeout) {
    if (wakeLock == null) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "PushSMS");
    }
    wakeLock.acquire(timeout);
    if (wifiLock == null) {
        WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        wifiLock = wm.createWifiLock("PushSMS");
    }
    wifiLock.acquire();
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            wifiLock.release();
        }
    }, timeout);
}
Also used : PowerManager(android.os.PowerManager) WifiManager(android.net.wifi.WifiManager) Handler(android.os.Handler)

Example 38 with WifiManager

use of android.net.wifi.WifiManager in project SmartAndroidSource by jaychou2012.

the class AssistTool method getWifiIp.

/**
	 * ��ȡ����wifi�����µ�ip��ַ
	 * 
	 * @return
	 */
public String getWifiIp() {
    WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
    int ip = wifiManager.getConnectionInfo().getIpAddress();
    return intToIp(ip);
}
Also used : WifiManager(android.net.wifi.WifiManager)

Example 39 with WifiManager

use of android.net.wifi.WifiManager in project Android-Terminal-Emulator by jackpal.

the class Term method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.v(TermDebug.LOG_TAG, "onCreate");
    mPrivateAlias = new ComponentName(this, RemoteInterface.PRIVACT_ACTIVITY_ALIAS);
    if (icicle == null)
        onNewIntent(getIntent());
    final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mSettings = new TermSettings(getResources(), mPrefs);
    mPrefs.registerOnSharedPreferenceChangeListener(this);
    Intent broadcast = new Intent(ACTION_PATH_BROADCAST);
    if (AndroidCompat.SDK >= 12) {
        broadcast.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
    }
    mPendingPathBroadcasts++;
    sendOrderedBroadcast(broadcast, PERMISSION_PATH_BROADCAST, mPathReceiver, null, RESULT_OK, null, null);
    broadcast = new Intent(broadcast);
    broadcast.setAction(ACTION_PATH_PREPEND_BROADCAST);
    mPendingPathBroadcasts++;
    sendOrderedBroadcast(broadcast, PERMISSION_PATH_PREPEND_BROADCAST, mPathReceiver, null, RESULT_OK, null, null);
    TSIntent = new Intent(this, TermService.class);
    startService(TSIntent);
    if (AndroidCompat.SDK >= 11) {
        int actionBarMode = mSettings.actionBarMode();
        mActionBarMode = actionBarMode;
        if (AndroidCompat.V11ToV20) {
            switch(actionBarMode) {
                case TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE:
                    setTheme(R.style.Theme_Holo);
                    break;
                case TermSettings.ACTION_BAR_MODE_HIDES:
                    setTheme(R.style.Theme_Holo_ActionBarOverlay);
                    break;
            }
        }
    } else {
        mActionBarMode = TermSettings.ACTION_BAR_MODE_ALWAYS_VISIBLE;
    }
    setContentView(R.layout.term_activity);
    mViewFlipper = (TermViewFlipper) findViewById(VIEW_FLIPPER);
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TermDebug.LOG_TAG);
    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    int wifiLockMode = WifiManager.WIFI_MODE_FULL;
    if (AndroidCompat.SDK >= 12) {
        wifiLockMode = WIFI_MODE_FULL_HIGH_PERF;
    }
    mWifiLock = wm.createWifiLock(wifiLockMode, TermDebug.LOG_TAG);
    ActionBarCompat actionBar = ActivityCompat.getActionBar(this);
    if (actionBar != null) {
        mActionBar = actionBar;
        actionBar.setNavigationMode(ActionBarCompat.NAVIGATION_MODE_LIST);
        actionBar.setDisplayOptions(0, ActionBarCompat.DISPLAY_SHOW_TITLE);
        if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
            actionBar.hide();
        }
    }
    mHaveFullHwKeyboard = checkHaveFullHwKeyboard(getResources().getConfiguration());
    updatePrefs();
    mAlreadyStarted = true;
}
Also used : PowerManager(android.os.PowerManager) ActionBarCompat(jackpal.androidterm.compat.ActionBarCompat) WifiManager(android.net.wifi.WifiManager) SharedPreferences(android.content.SharedPreferences) TermSettings(jackpal.androidterm.util.TermSettings) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 40 with WifiManager

use of android.net.wifi.WifiManager in project FileExplorer by MiCode.

the class FTPServerService method takeWifiLock.

private void takeWifiLock() {
    myLog.d("Taking wifi lock");
    if (wifiLock == null) {
        WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        wifiLock = manager.createWifiLock("SwiFTP");
        wifiLock.setReferenceCounted(false);
    }
    wifiLock.acquire();
}
Also used : WifiManager(android.net.wifi.WifiManager)

Aggregations

WifiManager (android.net.wifi.WifiManager)169 WifiInfo (android.net.wifi.WifiInfo)53 WifiConfiguration (android.net.wifi.WifiConfiguration)42 IOException (java.io.IOException)24 IntentFilter (android.content.IntentFilter)13 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)10 Context (android.content.Context)9 ConnectivityManager (android.net.ConnectivityManager)8 NetworkInfo (android.net.NetworkInfo)8 Test (org.junit.Test)8 Intent (android.content.Intent)7 File (java.io.File)6 SAXException (org.xml.sax.SAXException)6 SharedPreferences (android.content.SharedPreferences)5 PowerManager (android.os.PowerManager)5 TelephonyManager (android.telephony.TelephonyManager)5 X509Certificate (java.security.cert.X509Certificate)5 BufferedReader (java.io.BufferedReader)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileReader (java.io.FileReader)4