barx Well-Known Member Licensed User Longtime User Jul 14, 2014 #1 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
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 B4X founder Staff member Licensed User Longtime User Jul 15, 2014 #2 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
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.
barx Well-Known Member Licensed User Longtime User Jul 15, 2014 #3 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
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?
Erel B4X founder Staff member Licensed User Longtime User Jul 15, 2014 #4 Yes. Another option is to schedule a service to start every hour and try to upload again. Upvote 0
M monki Active Member Licensed User Longtime User Jul 17, 2014 #5 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
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
Erel B4X founder Staff member Licensed User Longtime User Jul 17, 2014 #6 Try this: Code: Copy Dim jo As JavaObject = StartingIntent Dim NetworkInfo As JavaObject = jo.RunMethod("getParcelableExtra", Array("networkInfo")) Log(NetworkInfo.RunMethod("getTypeName", null)) Log(NetworkInfo.RunMethod("getState", null)) Upvote 0
Try this: Code: Copy Dim jo As JavaObject = StartingIntent Dim NetworkInfo As JavaObject = jo.RunMethod("getParcelableExtra", Array("networkInfo")) Log(NetworkInfo.RunMethod("getTypeName", null)) Log(NetworkInfo.RunMethod("getState", null))
M monki Active Member Licensed User Longtime User Jul 17, 2014 #7 thanks erel it works fine monki Upvote 0