Android Question Wifi dis/connect service

mscientist33

Active Member
Licensed User
I have found this link: Wifi dis/connect

Could someone please explain how I would use this?

Is this a service that gets installed by itself then add the following to my Manifest in my main app?:

B4X:
AddReceiverText(SendNotification,
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE"/>
</intent-filter>)

How is the service started? etc?

Is there an example?

I have a tablet that will have a static ip address. I have multiple target devices that receive a UDP broadcast message, they decipher that message and checks it the message belongs to them, if so sends a response message back to the tablet ip address. All items (the tablet and the target items) will be connected to an access point. I need the tablet app to be able to tell the if connection is dropped from the tablet to the access point and even check if wifi is even turned on. Is the wifi dis/connect code what I should be using?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

mscientist33

Active Member
Licensed User
If that is an example, then how do I use it with my app? I need an example of it being used. Is the service installed as a seperate app? is it added to my app? The link doesn't show a new guy how to actually use it. If I just run the code in the zip file that is attached to the thread it opens up a blank app. If I look in the manifest for the service app it has:

B4X:
AddReceiverText(WifiService,
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE"/>
</intent-filter>)

then in the thread it says add:
B4X:
AddReceiverText(SendNotification,
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE"/>
</intent-filter>)

I need a little hand holding..... I add the second part to my app manifest and it gives me an "SendNotification" error.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
app manifest and it gives me an "SendNotification" error.
Hiding the complete Error is a BIG Mistake! How should we help with this Info?

SendNotification is a Servicemodule which must be added to your project too. Most probably it is part of the example app.
 
Upvote 0

mscientist33

Active Member
Licensed User
I do not see a SendNotification service module. Is this a library that needs to be added? It doesn't show in my list of library items. The question of Is the service installed as a seperate app? is it added to my app?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
is it added to my app?
You must add the service to your app.

As you can see in the example the Service added to the manifest is WifiService. WifiService is a Service in the example app.
I don´t know where you get the "SendNotification" from?
 
Upvote 0

mscientist33

Active Member
Licensed User
it says in the thread to add this to my manifest, notice the sendNotification in the text:

B4X:
AddReceiverText(SendNotification,
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE"/>
</intent-filter>)

This is where I get my error in compiling.
 
Upvote 0

mscientist33

Active Member
Licensed User
Okay, I have added the service to my app and added the following to my manifest:

B4X:
AddReceiverText(WifiService,

<intent-filter>

<action android:name="android.net.wifi.STATE_CHANGE"/>

</intent-filter>)

It compiles and my program runs. What exactly is this "service" supposed to do? I manually turn off my wifi while my app is running and nothing happens. Am I supposed to manually start the service?
 
Upvote 0

Serge Bertet

Active Member
Licensed User
Same problem for me: unable to make it working.
Turning #StartAtBoot: from false to true ... no way.
Switching Wifi from my router to my ESP32 access point ... nothing change.
Everybody looks to be happy with this code, it should works well.
I think an example app is missing.
I surely forget something ... but what?
 
Upvote 0
Top