how to set My Own android Hotspot Device name - android

I'm not asking about how to create a WIFIConfiguration
that I want to connect to.
But I'm asking how to set my own Device SSID for my own phone?
private WifiManager obWifiManager;
obWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = obWifiManager.getConnectionInfo();
sendMessage(wifiInfo.getSSID());
The above code has no setter method.
Only getter method. Please help!
I then stumbled upon this article. it said the configuration file is located almost there for any linux OS. There is an SSID setting over there!
So i search on that location but found none!
Probably android put it in a different order / place. Any clue?

Related

Does Android WifiManager saves the Config even without saveConfiguration()

I am developing and app for a restaurant. They want their customers to connect their Wifi via app.
The code:
WifiManager mManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiConfiguration config = new WifiConfiguration();
//Asume I added things to config.
int id = mManager.addNetwork(config);
mManager.enableNetwork(id, true);
So even if I don't call
myManager.saveConfiguration();
can the device connect that Router without my app?
Thank you for your time.
OK! I read about it more and more, I found the answer. And also the solution.
So, you need to use use
mManager.removeNetwork(id);
after it is disconnected. I assume you saved your BSSID's in somewhere. Also save the ID that you got. With a Timer task working at background check the current BSSID, if it is not the same, remove the ID from Configured Networks as above.
Here is how you check current BSSID:
WifiInfo wifiInfo = mManager.getConnectionInfo();
String currentBSSID = wifiInfo.getBSSID();

Android WiFi Connection Info

I'm getting wifi connection info this way:
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo();
But, could getConnectionInfo method return null in any case? Android documentation reference say this:
Return dynamic information about the current Wi-Fi connection, if any
is active.
I guess if the device is not connected to any network it will return null, won't it?
Thanks
Yes it will return null, if it is not connected to the wi-fi.
But if you are also checking whether internet is available by using above code, then it is not 100% correct way to do so.
Cause it may happen that your device is connected to wifi but no internet is available. so for that
you have to ping any live site (such as google,facebook, or any other trusted website) and check if the returned status code is 200.
I hope this helps.

Transmitting small amounts of information using WiFi SSIDs?

Is it possible to allow 2 Android devices to communicate by using SSIDs? One device would broadcast a message by creating a hotspot with the message as its SSID. Nearby devices can read and interpret the message. I couldn't find anything in the Android documentation that allow this. Is it possible on Android devices and how would I do this?
You can use this call to create a hotspot:
private boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled);
...
WifiConfiguration netConfig = new WifiConfiguration();
netConfig.SSID = "\"SSID_NAME\"";
// more configs here.
And to scan wifis around something like:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
List<ScanResult> results = wifi.getScanResults();
You can read the wifi info from there. Maybe you can identify the hotspot by MAC address.

How can I learn SSID of that I am connected to wifi point?

I want to learn the connected wif-fi point SSID. By doing so, I will not try to connect to the same point. How can I learn SSID of that I am connected to wifi point ? Is there a method like isConnected() ?
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
Log.d("wifiInfo", wifiInfo.toString());
Log.d("SSID",wifiInfo.getSSID());
you will need the android.permission.ACCESS_WIFI_STATE in your manifest
There is one problem:
I selected wifi "XYZ" whoz pwd was unknwn. Entered some random pwd.
It shows authentication problem. on wifi screen.
But, Log.d("SSID",wifiInfo.getSSID());
Results into "XYZ"

Can I find the MAC address of my Access point in Android?

Can my Android app find the MAC address of the Wifi access point it is connected to?
The docs for android.net.wifi.WifiInfo getMacAddress() don't provide any details.
See http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getMacAddress().
I'm assuming this is the Mac address of my phone. Can I find the Mac address of the access point?
getBSSID() of WifiInfo class will return MAC address of remote access point.
BSSID explained here.
The following method will return the MAC address of the access point, null if there is no network currently connected.
public String getMacId() {
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
return wifiInfo.getBSSID();
}
Check out the application "Network Info II" from the Android Market. It does show the MAC address, but I'm not sure if this is still the phone's MAC. It also shows the BSSID, which has the same format as a MAC address so perhaps is what you're looking for.
I'm fairly sure that getMacAddress(), is, as you suspected for the Local Device.
If you can get the IP of the router/gateway/accesspoint, then you might be able to use the code in this post: https://web.archive.org/web/20160308014312/http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/ to do your bidding. Good luck!

Categories

Resources