本文整理汇总了Java中android.net.wifi.WifiInfo类的典型用法代码示例。如果您正苦于以下问题:Java WifiInfo类的具体用法?Java WifiInfo怎么用?Java WifiInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WifiInfo类属于android.net.wifi包,在下文中一共展示了WifiInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWifiSSID
import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
* Gets the SSID of the currently associated WiFi access point if there is one. Otherwise,
* returns empty string.
*/
@CalledByNative
public static String getWifiSSID(Context context) {
if (context == null) {
return "";
}
final Intent intent = context.registerReceiver(
null, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
if (intent != null) {
final WifiInfo wifiInfo = intent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO);
if (wifiInfo != null) {
final String ssid = wifiInfo.getSSID();
if (ssid != null) {
return ssid;
}
}
}
return "";
}
示例2: GetWifiDBM
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public int GetWifiDBM() {
int dbm = 0;
WifiManager wifiManager = (WifiManager) _context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) {
return -1;
}
if (wifiManager.isWifiEnabled()) {
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
dbm = wifiInfo.getRssi();
}
}
return dbm;
}
示例3: getIpAddress
import android.net.wifi.WifiInfo; //导入依赖的package包/类
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;
}
示例4: b4
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public String b4() {
WifiInfo connectionInfo = this.hV.getConnectionInfo();
if (connectionInfo == null) {
return null;
}
try {
String bssid = connectionInfo.getBSSID();
if (bssid != null) {
bssid = bssid.replace(":", "");
if ("000000000000".equals(bssid) || "".equals(bssid)) {
return null;
}
}
bssid = null;
return bssid;
} catch (Exception e) {
return null;
}
}
示例5: getMacAddressByWifiInfo
import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
* <p>need permission {@code <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>}</p>
*/
@SuppressLint("HardwareIds")
private static String getMacAddressByWifiInfo(Context context) {
try {
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifi != null) {
WifiInfo info = wifi.getConnectionInfo();
if (info != null) return info.getMacAddress();
}
} catch (Exception e) {
e.printStackTrace();
}
return "02:00:00:00:00:00";
}
示例6: onReceive
import android.net.wifi.WifiInfo; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent)
{
WifiManager wifiMgr = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
String name = wifiInfo.getSSID();
for(ScanResult result: wifiMgr.getScanResults()){
WifiApListProvider.this.output(new WifiAp(result, name.equals(result.SSID)));
}
WifiApListProvider.this.finish();
}
示例7: getDeviceId
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String getDeviceId(Context context) {
String deviceID = null;
// MAC
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info;
if (wifi != null && (info = wifi.getConnectionInfo()) != null) {
deviceID = info.getMacAddress();
}
// TelephonyManager.DeviceId
String tmSerial = "null";
if (TextUtils.isEmpty(deviceID)) {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null) {
tmSerial = "" + tm.getSimSerialNumber();
deviceID = tm.getDeviceId();
}
}
// Settings.Secure.ANDROID_ID + TelephonyManager.SimSerialNumber
if (TextUtils.isEmpty(deviceID)) {
deviceID = generateId(context, tmSerial);
}
return deviceID;
}
示例8: getDeviceIpAddress
import android.net.wifi.WifiInfo; //导入依赖的package包/类
private InetAddress getDeviceIpAddress(WifiManager wifi) {
InetAddress result = null;
try {
// default to Android localhost
result = InetAddress.getByName("10.0.0.2");
// figure out our wifi address, otherwise bail
WifiInfo wifiinfo = wifi.getConnectionInfo();
int intaddr = wifiinfo.getIpAddress();
byte[] byteaddr = new byte[] { (byte) (intaddr & 0xff), (byte) (intaddr >> 8 & 0xff), (byte) (intaddr >> 16 & 0xff), (byte) (intaddr >> 24 & 0xff) };
result = InetAddress.getByAddress(byteaddr);
} catch (UnknownHostException e) {
e.printStackTrace();
Log.e(TAG, "getDeviceIpAddress Error: " + e.getMessage());
}
return result;
}
示例9: isHotelNewWork
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static boolean isHotelNewWork(Context context) {
WifiManager wifiManger = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
//获取wifi服务
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
//判断wifi是否开启
if (!wifiManager.isWifiEnabled()) {
return false;
}else {
WifiInfo wifiInfo = wifiManger.getConnectionInfo();
String localIp = intToIp(wifiInfo.getIpAddress());
if("192.168.43".equals(localIp))
return true;
else
return false;
}
}
示例10: a
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String a() {
try {
Context context = Global.getContext();
if (context == null) {
return "";
}
WifiManager wifiManager = (WifiManager) context.getSystemService("wifi");
if (wifiManager == null) {
return "";
}
WifiInfo connectionInfo = wifiManager.getConnectionInfo();
if (connectionInfo == null) {
return "";
}
return connectionInfo.getMacAddress();
} catch (Throwable e) {
f.b("MobileInfoUtil", "getLocalMacAddress>>>", e);
return "";
}
}
示例11: getConnectedSSID
import android.net.wifi.WifiInfo; //导入依赖的package包/类
/**
* This method retrieves the SSID for the currently connected network
*
* @param callbackContext A Cordova callback context
* @return true if SSID found, false if not.
*/
private boolean getConnectedSSID(CallbackContext callbackContext){
if(!wifiManager.isWifiEnabled()){
callbackContext.error("Wifi is disabled");
return false;
}
WifiInfo info = wifiManager.getConnectionInfo();
if(info == null){
callbackContext.error("Unable to read wifi info");
return false;
}
String ssid = info.getSSID();
if(ssid.isEmpty()) {
ssid = info.getBSSID();
}
if(ssid.isEmpty()){
callbackContext.error("SSID is empty");
return false;
}
callbackContext.success(ssid);
return true;
}
示例12: getCurrentSSID
import android.net.wifi.WifiInfo; //导入依赖的package包/类
public static String getCurrentSSID(Context context) throws Exception {
try {
WifiManager wifiManager = (WifiManager) context
.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
return wifiInfo.getSSID();
} catch (Exception e) {
throw new Exception("目前WIFI連線名稱讀取時發生錯誤");
}
}
示例13: checkWifiConnection
import android.net.wifi.WifiInfo; //导入依赖的package包/类
private void checkWifiConnection(){
try{
if(isWifiConnected()){
Toast.makeText(getApplicationContext(), "Wifi is connected", Toast.LENGTH_SHORT).show();
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
final String activeWifiName = wifiInfo.getSSID().replace("\"","");
btnActiveWifi.setText(activeWifiName);
//debug
btnActiveWifi.setText(btnActiveWifi.getText()+"\n("+AutoLoginService.getState(getBaseContext())+")");
}
else{
btnActiveWifi.setText("Wifi Not Connected !!");
//debug
btnActiveWifi.setText(btnActiveWifi.getText()+"\n("+AutoLoginService.getState(getBaseContext())+")");
}}
catch (Exception ex){
txtView.setText(ex.getMessage());
//Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG);
}
}
示例14: onBindHooks
import android.net.wifi.WifiInfo; //导入依赖的package包/类
@Override
protected void onBindHooks() {
super.onBindHooks();
addHook(new StaticHook("getConnectionInfo") {
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
WifiInfo info = (WifiInfo) super.call(who, method, args);
if (info != null) {
if (info.getMacAddress() != null) {
PhoneInfoDelegate phoneInfoDelegate = VirtualCore.get().getPhoneInfoDelegate();
if (phoneInfoDelegate != null) {
try {
Reflect.on(info).set("mMacAddress", phoneInfoDelegate.getMacAddress((String) Reflect.on(info).get("mMacAddress")));
} catch (Exception ignored) {
}
}
}
}
return info;
}
});
}
示例15: getMacAddress
import android.net.wifi.WifiInfo; //导入依赖的package包/类
@SuppressLint("HardwareIds")
public String getMacAddress() throws Exception {
WifiManager wifiMan = (WifiManager) mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiMan == null) {
return null;
}
WifiInfo wifiInf = wifiMan.getConnectionInfo();
if (wifiInf == null) {
return getMacByFile();
}
String mac = wifiInf.getMacAddress();
if (FAKE_MAC_ADDRESS.equals(mac)) {
mac = null;
}
if (mac == null) {
mac = getMacByInterface();
if (mac == null) {
mac = getMacByFile();
}
}
return mac;
}