This file contains hidden or 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
class DataSingletonActivity : AppCompatActivity(), View.OnClickListener { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_data_singleton) | |
val name = intent.getStringExtra("Name") | |
val phone = intent.getStringExtra("Phone") | |
activity_data_txtData.text = "Name : " + name + "\nPhone : " + phone |
This file contains hidden or 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
class SingletonActivity : AppCompatActivity(), View.OnClickListener { | |
private var edtName: EditText? = null | |
private var edtPhone: EditText? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
title = "Singleton Activity" | |
setContentView(R.layout.activity_singleton) |
This file contains hidden or 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
object UserModelSingleton { | |
var name: String? = null | |
var phone: String? = null | |
} |
This file contains hidden or 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
public class Singleton { | |
private static Singleton instance = null; | |
private Singleton(){ | |
} | |
private synchronized static void createInstance() { | |
if (instance == null) { | |
instance = new Singleton(); |
This file contains hidden or 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
class DataParcelableActivity : AppCompatActivity(), View.OnClickListener { | |
private var userModel: UserModelParcelable? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_data_parcelable) | |
userModel = intent.extras.getParcelable("UserModelParcelable") as UserModelParcelable |
This file contains hidden or 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
class ParcelableActivity : AppCompatActivity(), View.OnClickListener { | |
private var edtName: EditText? = null | |
private var edtPhone: EditText? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
title = "Parcelable Activity" | |
setContentView(R.layout.activity_parcelable) |
This file contains hidden or 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
data class UserModelParcelable(val name: String, val phone: String) : Parcelable { | |
constructor(source: Parcel) : this( | |
source.readString(), | |
source.readString() | |
) | |
override fun describeContents() = 0 | |
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) { | |
writeString(name) |
This file contains hidden or 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
class DataSerializableActivity : AppCompatActivity(), View.OnClickListener { | |
private var userModel: UserModelSerializable? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
title = "Data Serializable Activity" | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_data_serializable) | |
userModel = intent.extras.getSerializable("UserModelSerializable") as UserModelSerializable |
This file contains hidden or 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
class SerializableActivity : AppCompatActivity(), View.OnClickListener { | |
private var edtName: EditText? = null | |
private var edtPhone: EditText? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
title = "Serializable Activity" | |
setContentView(R.layout.activity_serializable) |
This file contains hidden or 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
data class UserModelSerializable(val name: String, val phone: String) : Serializable |
NewerOlder