Skip to main content

Posts

Showing posts from January, 2015

Layouts for Fragment

Fragments are use to develop dynamic and flexible or consistent User Interface(UI) design that can be supported by all screen sizes from small to large. In short, we can build Multi-pane UI using Fragments. We can divide the Activities into different reusable components which are known as Fragments. Fragments can be reused within multiple activities. Each Fragment has its own lifecycle and Layout and they are independent to each other that are embedded into an Activity. There are two class, Fragment and FragmentActivity that must be extended by the subclass of it. To know more about Fragment VS FragmentActivity. We can define a static or dynamic layout using Fragment.

Broadcast Receiver

In Android, Broadcast Receiver is a process of broadcasting particular event and receiver performs an action related to that event. When system/application broadcasts event (An event consists of particular message/intent), it triggers the receiver to execute service, activity or other application. Broadcast Receiver not actively running in memory.

Android Services

Services are always running in the background, which performs long operation. They don't have any UI(User Interface) Components. By default, Services and Activities both are runs in same application. An example of a service is, music player that plays music in background. Two states of Services are, Started  :  A service starts by calling  startService()  method and runs in background until it destroyed. Bounded  :  An application component can interact with the service using bounded service. The  bindService()  method used to bind the component with service. The bounded service should be Unbind before destroying that service.

Android Activity

To start an activity, we need to register each and every activity in the manifest file <activity  android:label ="@ string/ app_name "                         android:name =". MainActivity "> </ activity > In the above code, an activity name is MainActivity.