define the media types for a new post here Private static final DataHolder instance = new DataHolder() Here is the DataHolder class: import com.my_name.app_ Should I use Parcelable? (I don't like it though because doesn't it violate the single responsibility principle?) What would be the most efficient and easiest way to pass this Post object between the activities? Should I be using the Singleton class pattern here? I was looking through the Android docs on passing data between activites/services and needed a little help. When I would return to my app (presumably it had been killed) I would get a NullPointerException because the Post object was null. This was all working well until I ran into this issue. In the following activities, as the user enters more information about a post, I set the Post's properties. In every activity, I call DataHolder.getInstance() and when the create post button is clicked, I create a new Post object by executing: DataHolder.getInstance().setPost(new Post()). I switched from that solution to using a Singleton class called, DataHolder. My first (bad) solution was just to pass the data with the intent in a Bundle, but this soon got very messy as I really needed to pass a Post object between the activities. This process of creating a new post can potentially be a few activities/screens, so I need a way to save and pass the data between the activities. I'm making an Android app where users can create posts.
0 Comments
Leave a Reply. |