Comments (15)
Hi, the fragment being recreated is something the ViewPager does so that it doesn't keep too many fragments in memory at once. Please note that going back from the third stp to the first one is not the only scenario in which the first fragment will get recreated. This could also happen if e.g. you rotate the device or your app gets killed by the system and you go back to it.
The recommended approach here would be to save the data in a saved instance state. You could check out the sample app for an example: https://github.com/stepstone-tech/android-material-stepper/blob/master/sample/src/main/java/com/stepstone/stepper/sample/step/StepFragmentSample.java
from android-material-stepper.
Ok, but the problem that I'm facing isn't only the lose of values. The main problem is that in the first fragment, I use a library to pick an image and then put it in an ImageView, but when I return back from the third to the first fragment, and I try to pick the image, the app crashes because giving me error in onActivityResult: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity
. The library that I use in the first fragment is the following: https://github.com/jdamcd/android-crop. However I don't think it's a problem related to the library, because I changed it and the same problem occurred again...
from android-material-stepper.
Hi, I don't really know this library and without seeing the code there's actually very little I can do. Anyway, I believe the same issue might arise if the fragment was recreated in different scenarios mentioned by me earlier.
Are you sure you're using the library correctly, passing the right values as parameters, etc? Maybe this will help: http://stackoverflow.com/questions/20827237/failure-delivering-result-resultinfowho-null-request-1-result-1-data-intent ?
from android-material-stepper.
I think that I'm using it correctly, to start the crop activity. The library has the method startCrop(Context) or something like that, to start cropping the selected Image. But in a fragment this method is .startCrop(getActivity(), StepFragment.this). And it work until the fragment has been destroyed.
from android-material-stepper.
It looks lile an issue with the library to be honest or the the setup. The ViewPager in our library doesn't do anything special... Maybe this has something to do with jdamcd/android-crop#240 ? Does the crash occur if you try to start other activities and get the result from them?
from android-material-stepper.
No, I get the crash only if I use this library, but the problem occur also with another library. This is why i think it's not a library issue
from android-material-stepper.
Could you try it? Maybe I'm doing something wrong...
from android-material-stepper.
Hi, I'm currently on my holidays and I only have access to my phone :/ maybe you could fork this library and add the library you're using to the sample app so that I could have the look at the code at least?
from android-material-stepper.
Yes, I'll try. Keep in touch
from android-material-stepper.
Could you tell me the class where I can find the ViewPager? I mean the class in which you get it with .findViewById
from android-material-stepper.
from android-material-stepper.
Is there a way to access the ViewPager from my activity?
from android-material-stepper.
I want to try to use mViewPager.setOffScreenPageLimit(int) without modifying the library
from android-material-stepper.
Technically speaking the ViewPager is a view so you can find it and use it in the activity the same way it is found and used in the StepperLayout?
from android-material-stepper.
Solved. Using mViewPager.setOffScreenPageLimit(int)
solved the problem. As I thought it wasn't a problem related to the library. Thank you for your patience @zawadz88 👍
from android-material-stepper.
Related Issues (20)
- How to remove numbers from tabs? HOT 1
- Using a Singleton to keep data HOT 6
- Remove or Add Steps Conditionally HOT 1
- how to change icons and text in stepperLayout?
- How can i change the back button background with androidx HOT 1
- java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[])' on a null object reference HOT 6
- Is there any well-supported fork out there? HOT 6
- it takes much time to create the activity hosting stepper fragments (about secs which is very long for the UI Thread)
- Having Issue applying style on StepperLayout HOT 1
- Please find a solution to this problem
- verify
- Error
- Can't change back and next button text programmatically HOT 1
- Padding next button and final button HOT 1
- move library to mavenCentral or other repo, Jcenter() is Deprecated HOT 3
- The fragments inside stepper shrink completely when keyboard is opened
- Step fragment is not working properly after recalling HOT 1
- Adapter Position issue
- Implement in Kotlin DSL
- Change text color of inactive and active steps
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 android-material-stepper.