Created
April 19, 2021 16:14
-
-
Save rommansabbir/2a0b5907676d843d715c6aea668abe21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you have a list of data to pass through intent | |
// Don't do this: | |
intent.put("first", "something") | |
intent.put("second", 100.5) | |
intent.put("third", Object) | |
// Else, do this. | |
// Create a model | |
SomePayload(){ | |
var first : String = "" //default value | |
var second : Double = 0.0 | |
var third : Object = Object() | |
} | |
// Sender fragment or activity | |
intent.put("Payload", Gson().toJson(somepayload)) | |
// Receiver fragment or activity | |
val payload = Gson().fromJson(intent.getStringExtra("Payload"),SomePayload::class.java) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment