Android Question Hotspotlib error with Android 7, in Android 5 it works

welu1805

Active Member
Licensed User
Longtime User
Hi all, does anyone use the Hotspotlib?

In a class module I use the Hotspotlib:

B4X:
Sub Class_Globals
   Private HotSpot1 As Hotspotlib
End Sub

Public Sub Start(AServerName As String, AServerPassword As String)
   serverName = AServerName
   serverPassword = AServerPassword
  
   Msgbox("1", "")
  
   HotSpot1.tat
  
   Msgbox("2", "")
  
   HotSpot1.batdau(serverName, True, serverPassword)
  
   Msgbox("3", "")
End Sub

Msgbox("1", "") is showing but then is the error:

"An error has occurred in sub:clsserver_start
java.lang.reflect.InvocationTargetException"

Under Android 5 it works, but not under Android 7.

Has anyone an idea?
 

DonManfred

Expert
Licensed User
Longtime User
you can check the source and adapt it. The class is available of this lib.
I don´t know the Lib. even dont know what batdau is doing. Check the Classcode

Please note that the lib is around 5 years old. You should check it if it match the new requirements of android 7.

i chekced the class. there is no batdau or tat method... Are these your own methods? if yes; what are you doing there? Post the code
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Note that for Android 8+ you should use
i´m not sure this is the same as the Hotspot-library is providing. It can create a hotspot on the Screen and react on clicking such a hotspot.

It has nothing to do with a Wifi hotspot.

Hotspotlib
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
i´m not sure this is the same as the Hotspot-library is providing
I don't think it's referring to my Hotspot lib, I don't recognize the code or calls. And if it was working on Android 5, then it's not that library.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
I found the java-code to create a new wifi configuration:

// creating new wifi configuration
WifiConfiguration myConfig = new WifiConfiguration();
myConfig.SSID = ssid; // SSID name of netwok
myConfig.preSharedKey = password; // password for network
myConfig.allowedKeyManagement.set(4); // 4 is for KeyMgmt.WPA2_PSK which is not exposed by android KeyMgmt class
myConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); // Set Auth Algorithms to open - value is 0

I tried to do with B4A:

Dim myConfig As JavaObject

myConfig.InitializeNewInstance("android.net.wifi.WifiConfiguration", Null)
myConfig.SetField("SSID", Name)
myConfig.SetField("preSharedKey", Password)
a: myConfig.SetField("allowedKeyManagement", 4) ' 4 = WPA2
b: myConfig.SetField("allowedAuthAlgorithms", 0) ' 0 is necessary for WPA2

Line a and b are wrong because in java myConfig.allowedKeyManagement.set(4) the method ".set()" is a BitSet.
What can I do in B4A?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…