New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing typed parameters between activities #98
Comments
What is detailed implementation of |
Mine is this
|
Using static member ( |
Thanks, I was not aware of that. Here is the list of all possibilities http://stackoverflow.com/questions/4878159/android-whats-the-best-way-to-share-data-between-activities upd. official way http://developer.android.com/guide/faq/framework.html#3 |
The object assigned in a static field is not guaranteed to be persistent. It often became null. It is surprising that the official FAQ does not mention about this. Anyway, if you make your own singleton object, why does it need to be at
This kind of code is just enough. |
that was only my initial blunt implementation, it absolutely doesn't have to like for instance
and use this storage to get parameters passed among activities so regarding my initial thought to put those functions into scaloid - what do you think? |
+1 for the feature. I think the best way to do this would be to make use of macros and implement it like Android Annotations does, using extras. I'll try to do that when I have time. That should be a nice way to learn macros. |
Recent release of Scaloid includes more convenient way to pass values between activities:
This looks more natural because it can be translated one-to-one in plain English:
Please refer to this blog post for more detail: http://blog.scaloid.org/2014/10/scaloid-36-is-released.html#comment-form |
I believe the intent shorthand can be an effective solution for this issue, and if there are no further discussions about alternatives, I would close this issue. |
That's a good step forward, but still not a type-save. In my practice I usually pass only one param across the actions (DTO), and having ability to get it by type is very convenient and secure. So for now I'd stick with my own approach. |
Here I summarize the proposed solutions: Using
|
I'm very new to scaloid and scala but this got-typed-everything approach provided by scala is what makes development more controllable and thus exciting to me.
So when I was unable to find any scaloid-way of passing typed parameters between activities I've made my own. In my BaseActivity class I declared this two functions
which goes like this
I've found this pair of functions very convinient so I thought it would be cool to make them part of SActivity (rather TraitContext but anyway) itself.
I'll be glad to hear any feedback on this.
The text was updated successfully, but these errors were encountered: