Well, before taking in-deep look at reflection, please keep in mind that if it is imposible to use other method for operation, we should use this way rather than the reflection.
So, what is reflection? In the computer sience, reflection is the feature allows programs examine or modify runtime behaviour and structure of programs in the JVM. In Java language, reflection allows programs discover informations about classes, fields, interfaces and methods of loaded classes, and use them without any security restrictions.
Here is a quick example to you how Java reflection works :
After previous post we all understood basic Annotation’s terms, how to custom it, how to retrieve it at Runtime by reflection. To day, i’m going more deeply, such a writing Annotation processor, and integrate it with eclipse to reuse in a sample Android project.
Java SE5 provides a command-line utility for annotation processing, call Annotation processing tool or apt. It contains a set of reflective APIs and supporting infrastructure to process program annotations.
Since Java SE7, the apt tool and tis associated API have been deprecated, and are planned to be removed in next JDK release. Instead of it, use javac tool and APIs contained in the packages javax.annotation.processing and javax.lang.model to process annotations.
The term “French kiss” came into English language around 1923. In France it’s called a tongue kiss or soul kiss because if done right, it feels as if two soul ‘re merging.
The act of “French kissing” has difference names in difference countries. For example, people call it “French kissing” in the United States, Turkey, Chile and Nigeria. In UK, they simply call it “snogging”. In India, “French kiss” is sometimes referred to “English kiss” because of it more commonly appears in English films than the French. Excepcially, it is slang for fellatio in Australia. And in France, after centuries of lacking a French word for the term “French kiss”, the French finally give the verb “galocher” for it. It is also offical word in French dictionary. Continue reading
Annotations, called metadata, is additional information that embed into java source code file, and it can be used by complilers or developement tools for some purposes :
Informations for compiler. Annotations can be used by compiler to detect errors or superess warning.
Compile-time and deployment-time processing. IDEs can use annatations to generate code, XML file, ….
Runtime processing. Some annotations ‘re available to retrieve at runtime. Continue reading
Before coming with focus, let’s go through 2 scenarios :
– There’re some EditTexts on screen, the first is focused. When user press NEXT button on soft keyboard, the pointer will move to next one with order from left to right, top to bottom. So what should we do when need to change the default focus movement order on Android?
– When user focus on an EditText, platfrom makes it hightlight and shows soft keyboard up. And the question is how do we customize action happen when one view get focus ?
In my two cents, these’re the most common necessary knowledge when we work with focus on Android.
A view indicate its readiness to take focus through isFocusable() function. However we can change this attribute by call function setFocusable(boolean). Beside we also can specify view can take focus on touch mode or not through function setFocusableInTouchMode(boolean). After make view focusable, we can customize focus movement or action when focus happends. Continue reading
Sometimes we need only one instance of a class in whole system, and “Singleton” was born.
Singleton is the simplest pattern in the design pattern world. It invokes only one class which is responsible to instantite itself, to make sure no more than one instance of it was created. This class is used for centralized management of resources and provides global access point to itself. Continue reading