0

I am trying to make an Android Module and get WiFi SSID inside the module.

However, the

getApplicationContext() in

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService (Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo ();
String ssid  = info.getSSID();

function doesn't work inside the module.

How can I get the WiFi SSID string in an Android Module?

Yang
  • 67
  • 3

1 Answers1

0

You need to create a method in your android module to initialize the context. Then call that method from your main android application, better place to initialize the module context is Application#onCreate.

Krishna Sharma
  • 2,828
  • 1
  • 12
  • 23