Wish StartActivityForResult

LucaMs

Expert
Licensed User
Longtime User
I just added a post that indirectly concerns Intents, in the Question section.

Since I was in the beginning with B4A and I found StartActivityForResult in contextual help, I was hoping to use them. Then, I realized that this was not possible.

Yet, I believe that using the classic Eclipse with Java and Android, I think it is (I'm "new" in this world, I started with Eclise and I quickly abandoned it when I discovered the great B4A :))

In the end, I used some "techniques" that make my app like the old "spaghetti" programming.

I hope that B4A will allow this in the future
 

LucaMs

Expert
Licensed User
Longtime User
It is new for me too! (I started with B4A v.1.80, few months ago)

You can delete my Wish :)

(or not? Your answer can help someone).

Many many thanks!!!


P.S.

I'm reading your post about CallSubDelayed. You wrote:

"CallSubDelayed doesn't immediately call the target sub. It sends a message to the message queue. The internal framework manages this message and passes it to the target module when it is ready."

If I have understood correctly, the sub is executed immediately after the initialization of the activity, so if I need that the activity allows the user some operations, this is not possible. Right?

For example, the called activity allows for a search in a db and the activity that contains the CallSubDelayed should wait for the results, but after the user has entered the fields / filter and start the search.

Or call an activity to scan the camera from which I await the barcode
 

LucaMs

Expert
Licensed User
Longtime User
Both StartActivityForResult and CallSubDelayed methods do not return a result. You should use CallSubDelayed from the second activity to call a sub in the first activity (JobDone for example if you are familiar with HttpUtils2).

I could not edit my post (at the time the server does not allow this).

I wanted to add the sentence:

"I mean that it does not wait for a Activity.Finish, which is what normally would to me".

I'll have to reread Intents (as I wrote, I left immediately Eclipse and Android for B4A).

I thought I understood that you could get the result in an Intent (I have a bad bad memory :(:(:()
 

LucaMs

Expert
Licensed User
Longtime User
Wow. I have 2 bytes of memory working well. Yahooo :)

This is from here:

Sometimes you want to get a result back from an activity when it ends. For example, you may start an activity that lets the user pick a person in a list of contacts; when it ends, it returns the person that was selected. To do this, you call the startActivityForResult(Intent, int) version with a second integer parameter identifying the call. The result will come back through your onActivityResult(int, int, Intent) method.
 

LucaMs

Expert
Licensed User
Longtime User
Both StartActivityForResult and CallSubDelayed methods do not return a result. You should use CallSubDelayed from the second activity to call a sub in the first activity (JobDone for example if you are familiar with HttpUtils2).

No, I have not used HttpUtils2, but the name JobDone makes me think of a Sub who warns that the job is completed, a download for example, (like _BarcodeFound in ABZxing) but the job can not be an activity with its end (Activity.Finish).
 

LucaMs

Expert
Licensed User
Longtime User
For internal activities CallSubDelayed is more powerful. You should call the second activity and when the result is read call Activity.Finish and CallSubDelayed to return the result.

Sorry if I insist, but of course I did not understand.

In your last post, now it seems to me the opposite.

For example, if I had an activity of "utility/service", a sort of dialog (not a real dialog), I call it "D". What I want to achieve is:
Activity "A" calls "D", "D" finishes its work and returns a value, in this case to "A". Same thing from the other activities.

From this your post, it seems to me, instead:
Start D activity, prepare the result, close the activity using Acvitity.Finish and then CallSubDelayed (A.SubDone (Result)).

.........

I looked now, after writing the above, your example:
Using CallSubDelayed to interact between activities and services.

Inside it, you use CallSubDelayed in both activities, but this requires the caller to know the calling activity and its methods.

Probably I'm stubborn, but it seems to me that to get what I described, only StartActivityForResult might work.
 
Top