Benefit of using Parcelable instead of serializing object

From “Pro Android 2” NOTE: Seeing Parcelable might have triggered the question, why is Android not using the built-in Java serialization mechanism? It turns out that the Android team came to the conclusion that the serialization in Java is far too slow to satisfy Android’s interprocess-communication requirements. So the team built the Parcelable solution. The … Read more

Parcelable where/when is describeContents() used?

There is a constant defined in Parcelable called CONTENTS_FILE_DESCRIPTOR which is meant to be used in describeContents() to create bitmask return value. Description for CONTENTS_FILE_DESCRIPTOR in the API ref is: Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled. Which really means: If … Read more

How to use @Parcelize now that kotlin-android-extensions is being deprecated?

This should be the new plugin: https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.parcelize If using Plugins DSL you can use the plugin ID in submodules. Make sure that the latest Kotlin Android plugin is available from the project’s classpath. // project build.gradle plugins { .. id “org.jetbrains.kotlin.android” version “1.4.20” apply false } // app build.gradle plugins { .. id ‘kotlin-parcelize’ } … Read more

How to send objects through bundle

You can also use Gson to convert an object to a JSONObject and pass it on bundle. For me was the most elegant way I found to do this. I haven’t tested how it affects performance. In Initial Activity Intent activity = new Intent(MyActivity.this,NextActivity.class); activity.putExtra(“myObject”, new Gson().toJson(myobject)); startActivity(activity); In Next Activity String jsonMyObject; Bundle extras … Read more

Is there a convenient way to create Parcelable data classes in Android with Kotlin?

Kotlin 1.1.4 is out Android Extensions plugin now includes an automatic Parcelable implementation generator. Declare the serialized properties in a primary constructor and add a @Parcelize annotation, and writeToParcel()/createFromParcel() methods will be created automatically: @Parcelize class User(val firstName: String, val lastName: String) : Parcelable So you need to enable them adding this to you module’s … Read more

Android: Difference between Parcelable and Serializable?

In Android we cannot just pass objects to activities. To do this the objects must either implement Serializable or Parcelable interface. Serializable Serializable is a standard Java interface. You can just implement Serializable interface and add override methods. The problem with this approach is that reflection is used and it is a slow process. This … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)