how to get MacID of mobiledevice in android?
try this
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String MACAddress = wifiInfo.getMacAddress();
Related
The problem:
When I connect to wifi, and then disconnect, the following code gives me SupplicantState.COMPLETED
SupplicantState supState;
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
supState = wifiInfo.getSupplicantState();
Is it possible to trigger an update of the scan result for wifi on an Android phone? So when you use the example code below you dont get cashed values.
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
List<ScanResult> results = wifiManager.getScanResults();
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.startScan();
List<ScanResult> results = wifiManager.getScanResults();
I am using below code to remove or forgot configure Wi-Fi network:
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.removeNetwork(networkID);
but its not working in os 6.0, please suggest?
You should use like this:
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
int networkId = wifiManager.getConnectionInfo().getNetworkId();
wifiManager.removeNetwork(networkId);
wifiManager.saveConfiguration();
Hope it will helps you !!
I want to know Mobile number and Wi-Fi-Address .Howis this possible.Can anyone Help me
try this for Mobile Number
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
String phone = tm.getLine1Number();
but its not always reliable on for example non phone device. You will also need to add permision "android.permission.READ_PHONE_STATE".
for MAC address
WifiManager wfManager;
WifiInfo wifiinfo;
wfManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
wifiinfo = wfManager.getConnectionInfo();
String MAC = wifiinfo.getMacAddress();
public String getMAC() {
wifimanager= (WifiManager)getSystemService(Context.WIFI_SERVICE);
wifiinfo = wifimanager.getConnectionInfo();
MAC=wifiinfo.getMacAddress();
System.out.println("MAC address info---- "+MAC);
Toast.makeText(getApplicationContext(), "MAC address:"+MAC , Toast.LENGTH_LONG).show();
if(MAC==null){
MAC="1A:DC:5C:8E:15:7B";
}
return MAC;
}
how to get macid and mobile number only in android mobile device not in database
try this
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = manager.getConnectionInfo();
String MACAddress = wifiInfo.getMacAddress();