Log.v(“ThreeTips”, ”#14”)
1 — TransactionTooLarge Exception on Nougat Devices
We all know what TransactionTooLarge(TTL) Exception means. When you persist your data to bundle to support landscape mode in your app, you need to think about twice. What is your data size? Another question, what is bundle limit? We will come to this later.
The platform has been printing warning log about this for a while, but let’s be honest, who has time to read all the logs? Nougat (API 24) throws
TransactionTooLargeException
s asRuntimeException
s, so we cannot ignore that any more.
What is solution? There are couple of solution to solve this. First of all, Don’t use bundle to support rotation support, If your data size is over than 100kb. Instead of that, you can use Loader or worker fragment. I suggest you to use worker fragment, because you can also handle ongoing api calls with worker fragment.
So what is bundle limit? From Android documentation;
The Binder transaction buffer has a limited fixed size, currently 1Mb…
From Source Code
if (canThrowRemoteException && parcelSize > 200*1024) {
...
exceptionToThrow = "android/os/TransactionTooLargeException";
...
}
So 200 KB? Anyway, better you keep it smaller than 200 KB. But I will be appreciate If anyone can light me up about this inconsistent documentation.
2— applicationId vs packageName
Some of us think that applicationId and packageName are same.They are same initially so it is normal that we can think like that. We are wrong. When you create a new project in Android Studio, the applicationId
exactly matches the Java-style package name you chose during setup.However, the application ID and package name are independent of each other.
So you can change package name later on. It will not affect the application ID. And also when you change applicationId, package name will not be affected. But It is important to know that you can not publish you app with different applicationId when it is published once.
Application ID looks like package name, but it has some restricted rules;
- It must have at least two segments (one or more dots).
- Each segment must start with a letter.
- All characters must be alphanumeric or an underscore [a-zA-Z0–9_].
3 — SwitchCompat Check Listener Problem
If you use SwitchCompat in your adapter item, better you debug your onCheckedChange
of your SwitchCompat. Because it is sometimes called automatically. If you want to handle this problem there is an api method, buttonView.isPressed()
. This method tells you If user clicked your switch.
Happy coding.