Android Question jRDC2 & New Activties

Revisable5987

Member
Licensed User
I have found when using jRDC2 that if a new activity is started before a request has finished in the first activity, the new activity will close once the request has finished.

E.G
The app is opened, which starts the DB request.
The user immediately clicks on a button which starts a new activity.
** Activity (Main) Pause, UserClosed = false **
** Activity (Second) Create, isFirst = true **

The DB returns a result which then causes:
** Activity (Main) Resume **

I guess this makes sense as RequestManager returns the result to the Activity from which it was started.

Is there anyway of stopping this from happening apart from calling activity.finish in Activity(Main) when starting Activity(Second)?
 

Revisable5987

Member
Licensed User
I've tried, which has the same effect. If the activity is changed before a result is returned then the old activity will resume once the result is returned.
B4X:
Public Sub CreateRequest (Activity As Object)As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(Activity, rdcLink)
    Return req
End Sub

Public Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    If Parameters <> Null Then cmd.Parameters = Parameters
    Return cmd
End Sub
And, from what I can understand, here the result is being returned to the started service and not the activity?
B4X:
Public Sub CreateRequest As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(me, rdcLink)
    Return req
End Sub

Public Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    If Parameters <> Null Then cmd.Parameters = Parameters
    Return cmd
End Sub

Is there a another way I should be looking at this?

Also, as a side note.
This is made 100x worse when I turn off the database (to emulate no/poor signal on device)
In this case everytime
ResponseError. Reason: java.net.SocketTimeoutException: failed to connect to /192.168.1.21 (port 17178) from /192.168.200.2 (port 34736) after 30000ms, Response:
is logged, the activity will return to the one that made the request.
 
Upvote 0

Revisable5987

Member
Licensed User
The activity will not be started if you send the request from the starter service.
Do you mean put the above code in the starter service?

If so, that is what I tried, sorry I forgot to actually put that.

Otherwise I'm not entirely sure what you mean
 
Upvote 0

Revisable5987

Member
Licensed User
Okay thanks @Erel

Hopefully this is what you meant
I've attached an example that I made to try it out, if anyone wants to let me know if I did the correct thing. ?
 

Attachments

  • Example.zip
    31.8 KB · Views: 214
Upvote 0
Top