Welcome Android TestHotSpot.
This project is created to enable Android developer to manage hotspot problematically in easy way. This project also contains some useful api's as well. To get overview of API's please visit javadoc of this project at http://mady4ever.github.io/TestHotspotdoc/ ,,,
This Project contains mainly following classes.
wifiHotSpots
Helps You To Connect To Hotspot , Get All Hotspots Around You, Sort All Hotspots By Signle Level, Start Device Local Hotspot , Start and Stop Scanning For Hotspots Or You Can Use Time For Scanning Periodically, Check If Device is Connect To Hotspot , Check If Device Local Hotspot is turned on , Get Signal Frequency or Level…..
Some examples. Considering hotutil is object created like following.
wifiHotSpots hotutil =new wifiHotSpots(this);
Start HotSpot.
if(hotutil.startHotSpot(true)){
Toast.makeText(getApplicationContext(), " Device HotSpot is Turned On", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Device HotSpot is Not Turned On", Toast.LENGTH_LONG).show();
}
Stop HotSpot.
if(hotutil.startHotSpot(false)){
Toast.makeText(getApplicationContext(), " Device HotSpot is Turned Off", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Device HotSpot is Not Turned Off", Toast.LENGTH_LONG).show();
}
Change SSID and PASSWORD of hotspot.
if(hotutil.setHotSpot("SSID","PASSWORD")){
Toast.makeText(getApplicationContext(), " SSID And PassWord Of Device HotSpot is Chonged ", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "SSID And PassWord Of Device HotSpot Not Chonged", Toast.LENGTH_LONG).show();
}
Connect to Specific HotSpot.
if(hotutil.connectToHotspot("SSID2", "Password")){
Toast.makeText(getApplicationContext(), " Device is Connected to This HotSpot ", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Device is Not Connected to This HotSpot", Toast.LENGTH_LONG).show();
}
Add Wifi N/W.
hotutil.addWifiNetwork("ssid22", "pass", "WEP"); //last parameter can be "OPEN","WEP" or "WAP"
Remove Wifi N/W.
hotutil.removeWifiNetwork("ssid22");
List/Scan available N/W's ` List results = hotutil.getHotspotsList();
for (ScanResult result : results) {
Toast.makeText(getApplicationContext(), result.SSID + " " + result.level,
Toast.LENGTH_SHORT).show();
}
`
Sort available by lavel. ` List results2 = hotutil.sortHotspotsByLevel();
for (ScanResult result : results2) {
Toast.makeText(getApplicationContext(), result.SSID + " "+ result.level,
Toast.LENGTH_SHORT).show();
}
`
Start Scan periodically.
hotutil.startScan(1,50000);
Stop Scan.
hotutil.stopScan();
wifiStatus
Helps You To Check If Device Is Support Wifi or Wifi direct, Check If Wifi Is Enabled Or Not , Turn On Off And Toggle Wifi, Check If Device Is Connect To Internet Or Not , Get SSID,BSSID,RSSI,Link Speed,Signal Strength, Get Type Of Connection Used By Mobile Now All This Just Use One Method checkWifi(int state)
Some examples of wifiStatus. Considering wifiStatus object is created like following.
` WifiStatus wu = new WifiStatus(this);
`
Check Device Support Wifi.
`
if(wu.checkWifi(wu.SUPPORT_WIFI)){
Toast.makeText(getApplicationContext(), "Yes Device Support Wifi", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No Device Not Support Wifi", Toast.LENGTH_LONG).show();
}
`
Check Device Support Wifi Direct.
`
if(wu.checkWifi(wu.SUPPORT_WIFI_DIRECT)){
Toast.makeText(getApplicationContext(), "Yes Device Support Wifi Direct", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No Device Not Support Wifi Wifi Direct", Toast.LENGTH_LONG).show();
}
`
Check Wifi Is On.
`
if(wu.checkWifi(wu.IS_WIFI_ON)){
Toast.makeText(getApplicationContext(), "Yes Wifi Is Tured On", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Wifi Is Tured Off", Toast.LENGTH_LONG).show();
}
`
Turn on WIFI.
`
if(wu.checkWifi(wu.WIFI_ON)){
Toast.makeText(getApplicationContext(), " Yes Wifi Is Tured On", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Wifi Not Tured On", Toast.LENGTH_LONG).show();
}
`
Turn Off WIFI.
`
if(wu.checkWifi(wu.WIFI_OFF)){
Toast.makeText(getApplicationContext(), " Wifi Is Tured Off", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Wifi Not Tured Off", Toast.LENGTH_LONG).show();
}
`
Check Wifi Connected to HotSpot.
`
if(wu.checkWifi(wu.CONECT_HOTSPOT)){
Toast.makeText(getApplicationContext(), "Yes Device is Coneceting To Hostspot", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No Device is Not Coneceting To Hostspot", Toast.LENGTH_LONG).show();
}
`
Check Connected to Internet.
`
if(wu.checkWifi(wu.CONECT_INTERNET)){
Toast.makeText(getApplicationContext(), "Yes Device is Coneceting To Internet", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No Device is Not Coneceting To Internet", Toast.LENGTH_LONG).show();
}
`
Check Device is Connected to Internet via Wifi.
`
if(wu.checkWifi(wu.DATA_BY_WIFI)){
Toast.makeText(getApplicationContext(), "Yes Device is Coneceting Via Wifi", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "No Device is Not Coneceting Via Wifi", Toast.LENGTH_LONG).show();
}
`
Misc. api's
`
Toast.makeText(getApplicationContext(), "BSSID "+wu.getBSSID()+"\n"+"RSSI "+wu.getRSSI()+"\n"+"SSID "+wu.getSSID()+"\n"+"SIGNL STRENGHT "+wu.getSignalStrength()+"\n"+"LINK SPEED "+wu.getLinkSpeed()+"\n"+wu.getLinkSpeedUnits(), Toast.LENGTH_LONG).show();
`
wifiSocket
Helps You To Send And Receive Text Message In Wifi Network, Send And Receive File In Wifi Network Using Socket.
Examples:-
Considering object is created like following.
` WifiSocket ws = new WifiSocket(this);
`
Send Message to specific ip and port.
`
ws.sendMessage("192.168.1.102",5000,"Message from Heaven");
`
Receive Message at specifc Port.
`
ws.receiveMessage(5000, 10, new Runnable() {
@Override
public void run() {
((Activity)mContext).runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), ":::"+ws.receivedMessage+":::",
Toast.LENGTH_SHORT).show();
}
});
Log.i("Receive text :: ",":::"+ws.receivedMessage+":::" );
}
});
`
Send File.
`
ws.sendFile("192.168.1.102", 5000, Environment.getExternalStorageDirectory()+File.separator+"test.pdf");
`
Receive File.
`
ws.receiveFile(5000, Environment.getExternalStorageDirectory()+File.separator+"test.pdf");
`
wifiAddresses
Helps You To Get All Devices Connect to HotSpot Get Gateway, Device Ip Address Or MAC Address, Ping IP Address And Get Result Of Pinging IP, Get MAC Address From ARP File, Check If IP Live Using DNS Or ARP File Or Using Socket And PORT,
Examples.
Considering object is created like.
wifiAddresses au = new wifiAddresses(this);
Gateway Ip/Mac Device Mac/Ip etc.
`
Toast.makeText(getApplicationContext(),"GatWay IP:" +au.getGatewayIPAddress()+"\n"+"GatWay MAC"+au.getGatWayMacAddress()+"\n"+"Device IP"+au.getDeviceIPAddress()+"\n"+"Device MAC"+au.getDeviceMacAddress(),
Toast.LENGTH_SHORT).show();
`
Ping to Specific Ip.
`
if(au.pingCmd("192.168.1.101")){
Toast.makeText(getApplicationContext(), "This IP is Live",
Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(), "No This IP Not Live",
Toast.LENGTH_SHORT).show();
}
`
Get Ping result.
` Toast.makeText(getApplicationContext(), au.getPingResulta("192.168.1.101"), Toast.LENGTH_SHORT).show();
`
Get Mac from arp request.
Toast.makeText(getApplicationContext(), au.getArpMacAddress("192.168.1.101"),
Toast.LENGTH_SHORT).show();
Check DNS is live.
`
au.dnsLive("192.168.1.101",new Runnable() {
public void run() {
((Activity)mContext).runOnUiThread(new Runnable() {
public void run() {
if(au.isDnsLive){
Toast.makeText(getApplicationContext(), "This IP is Live Using Dns Test",
Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(), "This IP is Not Live Using Dns Test",
Toast.LENGTH_SHORT).show();
}
}
});
}
});
`
Check Port live.
`
au.portLive("192.168.1.101",new Runnable() {
public void run() {
((Activity)mContext).runOnUiThread(new Runnable() {
public void run() {
if(au.isDnsLive){
Toast.makeText(getApplicationContext(), "This IP is Live Using Socket with some Ports test ",
Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(), "No This IP Not Live Using Socket with some Ports test",
Toast.LENGTH_SHORT).show();
}
}
});
}
});
`
Get All devices ip.
`
List<String> results3 = au.getAllDevicesIp();
for (String result : results3) {
Toast.makeText(getApplicationContext(),result,
Toast.LENGTH_SHORT).show();
}
`
Check Device is Rooted.
`
au.CheckRoot();
`
Misc.
` //set static Ip.
public void setStaticIpInfo(String ip,String netMask,String gateWay,String dns1,String dns2)
`
Support or Contact
Mail me at patel.mdkumar@gamil.com for any help or support.