-2

I am very new to stackoverflow so I am trying to keep my question short and intelligible. And im sorry for my bad english :P

In my App, im trying to get the network status of my phone when it made a hotspot. I know how to get the Wifi status or the Mobile status for example, but in what Status is my smartphone if it opened a Hotspot?

What I got until now is how to check if the device got WIFI on, and that's how:

connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();

So the question is how do I check if the device opened a Hotspot or not?

Best Regards, Alex

Cat
  • 66,919
  • 24
  • 133
  • 141
  • The answer lies in using the undocumented `WIFI_AP_STATE_ENABLED` will tell you that the hotspot was opened, also the intent `WIFI_AP_STATE_CHANGED_ACTION` is the key to your answer! – t0mm13b Jan 05 '13 at 19:37
  • Can you tell me an example of how a method that returns TRUE if the device opened a hotspot would look like? I dont really know how this would look like, I also cant find anything like that via Google. – user1950262 Jan 07 '13 at 11:45

1 Answers1

-1

You can use WifiManager. Retrieve an instance using:

WifiManager wmgr = (WifiManager) getSystemService(WIFI_SERVICE);

and then, using wmgr.getConnectionInfo(), you can get information on the current connection to a hotspot.

Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80
  • thanks for the fast response! But what do I get returned if the device im on opened a hotspot? – user1950262 Jan 05 '13 at 13:02
  • I believe you will get a [`WifiInfo`](http://developer.android.com/reference/android/net/wifi/WifiInfo.html) object. I believe if it's null that means you're not connected to a hotspot. – Oleg Vaskevich Jan 05 '13 at 18:44
  • The OP is asking how to detect if the device has activated a WiFi tethering hotspot.. :) – t0mm13b Jan 05 '13 at 20:10
  • Oh... keyword "tethering" makes all the difference. OP was not clear with what he wanted to do; don't see how that justifies a downvote. :( – Oleg Vaskevich Jan 05 '13 at 20:12
  • A quick search turned up [some results](http://stackoverflow.com/questions/9065592/how-to-detect-wifi-tethering-state) – Oleg Vaskevich Jul 21 '14 at 14:38