Comments (10)
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.
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.
I suppose it is possible. I will think this through.
from alligator.
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.
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.
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.
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.
While I understand you point I still think that an activity can be in the back stack and been killed then recreated
from alligator.
I have checked that onNewIntent
is called even if an activity has been recreated.
from alligator.
Version 2.2.0 with this feature is released.
from alligator.
Related Issues (20)
- Question: How to get the activity result from a fragment? HOT 1
- Nested fragment ScreenSwitcher HOT 1
- Integration with AAC Navigator HOT 1
- Fragment BackStack Handling HOT 4
- Navigation tree HOT 2
- In which case getScreen can return null ? HOT 5
- Kotlin HOT 2
- Translucent activity not finished with result HOT 4
- It makes sense to have a method returning the current screen (and maybe the activity/fragment) on AndroidNavigator? HOT 1
- AndroidX HOT 3
- Can an Instagram Like navigation be done with this Library HOT 2
- Cannot generate Class HOT 1
- Help Needed HOT 8
- screenResolver.getScreen() returns null HOT 4
- [Improvement] Make a new navigator method to keep already loaded Fragments. HOT 1
- Pop fragments/screens if HOT 2
- Fragments and ViewPager HOT 3
- Passing ScreenResult from one fragment to another fragment HOT 9
- "Race condition" when using switchTo() HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alligator.