Skip to main content

Posts

Service in Android

Service in Android A Service is an application component that can perform long-running operations in the background, and it doesn't provide a user interface. Another application component can start a service, and it continues to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform inter process communication (IPC). For example, a service can handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background. These are the three different types of services: Foreground   A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a Notification . Foreground services continue running even when the user isn't interacting with the app.   Background   A background service performs a
Recent posts

Activity Life Cycle States

      Activity Life Cycle Example  https://drive.google.com/file/d/1ald91YAfWEit05irie7NolPm4h1OFpIy/view?usp=sharing Activity Life Cycle         As a user navigates through, out of, and back to your app, the Activity instances in your app transition through different states in their lifecycle. The Activity class provides a number of callbacks that allow the activity to know that a state has changed: that the system is creating, stopping, or resuming an activity, or destroying the process in which the activity resides.       Within the lifecycle callback methods, you can declare how your activity behaves when the user leaves and re-enters the activity. For example, if you're building a streaming video player, you might pause the video and terminate the network connection when the user switches to another app. When the user returns, you can reconnect to the network and allow the user to resume the video from the same spot. In other words, each callback allows you

#3: Collapsing Toolbar

Collapsing Toolbar         CollapsingToolbarLayout is a ViewGroup that provides many of the visual characteristics and interactions for collapsing toolbars specified in the material guidelines. To create the collapsing toolbar, CollapsingToolbarLayout integrates with AppBarLayout, CoordinatorLayout, Toolbar, and a scrollable content view, such as RecyclerView. How to work with Collapsing Toolbar:     To add a collapsing toolbar to your layout, place the CollapsingToolbarLayout inside an AppBarLayout. Then, add a Toolbar and any other views as a child to the CollapsingToolbarLayout. Make sure that the entire view structure is inside a CoordinatorLayout to take advantage of CollapsingToolbarLayout’s scrolling and features. Sample Code: <android.support.design.widget.CoordinatorLayout     android:layout_width="match_parent"     android:layout_height="match_parent">     <!-- Scrollable view here -->   <com.google.android.mat

#2: SQLite database

SQLite What is SQLite? SQLite is an Open Source Database which is embedded into Android. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. In addition it requires only little memory at runtime (approx. 250 KByte). SQLite supports the data types   TEXT   (similar to String in Java),   INTEGER   (similar to long in Java) and REAL   (similar to double in Java). All other types must be converted into one of these fields before saving them in the database. SQLite itself does not validate if the types written to the columns are actually of the defined type, e.g. you can write an integer into a string column and vice versa. SQLite in Android? SQLite is available on every Android device. Using an SQLite database in Android does not require any database setup or administration. You only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed fo

#1: Layouts in Android

Layouts A layout defines the structure for a user interface in your app, such as in an  activity . All elements in the layout are built using a hierarchy of  View  and  ViewGroup  objects. A  View  usually draws something the user can see and interact with. Whereas a  ViewGroup  is an invisible container that defines the layout structure for  View  and other ViewGroup  objects, as shown in figure 1. Figure 1.  Illustration of a view hierarchy, which defines a UI layout The  View  objects are usually called "widgets" and can be one of many subclasses, such as  Button  or  TextView . The  ViewGroup  objects are usually called "layouts" can be one of many types that provide a different layout structure, such as  LinearLayout  or  ConstraintLayout   . You can declare a layout in two ways: Declare UI elements in XML . Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and l