Giter VIP home page Giter VIP logo

Comments (10)

aartikov avatar aartikov commented on May 27, 2024

No, it doesn't. Alligator uses startActivityForResult and setResult to pass a result. So a result can be returned to a previous activity only.

from alligator.

AlexisQapa avatar AlexisQapa commented on May 27, 2024

So there is no way build build something like goBackToWithResult ?

the flag Intent.FLAG_ACTIVITY_FORWARD_RESULT allow to forward a result to the parent of the parent if the parent if finished.

from alligator.

aartikov avatar aartikov commented on May 27, 2024

I suppose it is possible. I will think this through.

from alligator.

AlexisQapa avatar AlexisQapa commented on May 27, 2024

I found that this flag also have its flaws as depending of activities count in the flow it's hard to manage something that always works. I have another lead though we can always start activities for results, as I think this is what you already do, and always finish if result is ok but not handled.
handleResult() else if (resultCode == RESULT_OK) { // If there is a result but we can't handle it, we should be in a flow so stop and pass the result to child setResult(resultCode, data) finish() }

what do you think about this ?

from alligator.

aartikov avatar aartikov commented on May 27, 2024

Thank you for the good ideas.
Passing result by chain will likely work, but it will require significant changes in a library. I don't start every activity for result, just activities that are registered appropriately. I also use request codes to identify how to retrieve a result from an intent.

So I decided to pass a result directly from the last activity to the first one in the chain through onNewIntent callback. It works fine. I push my current progress to this branch https://github.com/aartikov/Alligator/tree/feature/go-back-to-with-result
I will recheck if everything is ok and make a release soon.

from alligator.

AlexisQapa avatar AlexisQapa commented on May 27, 2024

Nice job on the branch ! One thing thought, I think on newIntent is not called if the activity was destroyed and the intent would be passed in onCreate. So both methods should call the code that handle the resutlt according to http://www.helloandroid.com/tutorials/communicating-between-running-activities. It's an old link but I didn't found any thing clearer than this.

from alligator.

aartikov avatar aartikov commented on May 27, 2024

No, result handling should not be called in onCreate, because getIntent() will return an intent that started an activity, but not the one that was used to go back to it.
I assume that nobody will goBackTo or goBackToWithResult to the screen that is not present in the stack. It would be ideally to get ScreenNotFoundException in that case (as it happens with fragment screens), but I have not found a way to implement it reliably for activities.

from alligator.

Alex293 avatar Alex293 commented on May 27, 2024

While I understand you point I still think that an activity can be in the back stack and been killed then recreated

from alligator.

aartikov avatar aartikov commented on May 27, 2024

I have checked that onNewIntent is called even if an activity has been recreated.

from alligator.

aartikov avatar aartikov commented on May 27, 2024

Version 2.2.0 with this feature is released.

from alligator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.