Android Question Detect Connection change

barx

Well-Known Member
Licensed User
Looking at PhoneEvents you cat detect a connection change.

How does this work exactly, Does it add a broadcast receiver that will launch the service on the change event.

If not, is this possible.

I'm creating an app that uploads data through a RESTful website api, but the info can only be uploaded if a net connection is available. If the connection is not available then store data in a DB. I want the app to start uploading when a valid connection is available even if the app is in a closed state.

clues??

thanks
 

Erel

Administrator
Staff member
Licensed User
The PhoneEvents library creates a dynamic intent. This means that it will only intercept events when the process is running.

You can create a static intent for android.net.conn.CONNECTIVITY_CHANGE: Intent Filters - Intercepting SMS messages in the background

You will need to use JavaObject to extract the network information.
 
Upvote 0

barx

Well-Known Member
Licensed User
Thanks, Since posting this I have create a UploadService and if the connection is bad the service is turned foreground informing the user of the state and why it hasn't uploaded yet. Then the notification will show the upload progress and then stop foreground as no need to listen to connection change anymore.

This will also pretty much ensure the process is kept alive to detect the dynamic listener...

Sound like a good plan?
 
Upvote 0

monki

Active Member
Licensed User
I have a similar problem with a static intent for android.net.conn.CONNECTIVITY_CHANGE.
how can I get the extra data using the Java Object.
monki
 
Upvote 0
Top