Category «Android Basics»

RelativeLayout in Android

The RelativeLayout is the most powerful layout available. All children in a RelativeLayout can be positioned relative to each other or to their parent. For example : you can tell a view to be positioned to the left or right of another view. Or, you can specify that a view is aligned to the bottom …

LinearLayout in Android

A LinearLayout is a layout that arranges its children either horizontally or vertically, depending on the value of its orientation property. The LinearLayout is the easiest layout to use. A LinearLayout can also have a gravity attribute that affects its gravity. A horizontal LinearLayout Example <LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android” xmlns:tools=“http://schemas.android.com/tools” android:orientation=“horizontal” android:layout_width=“match_parent” android:layout_height=“match_parent”> <ImageButton android:src=”@android:drawable/btn_star_big_on” android:layout_width=“wrap_content” android:layout_height=“wrap_content”/> …

Android Layouts

Layouts are important because they directly affect the look and feel of application. Technically, a layout is a view that arranges child views added to it. Android comes with a number of built-in layouts, ranging from LinearLayout, which is the easiest to use, to RelativeLayout, which is the most powerful. Layout Overview An important Android component, …

Android PendingIntent Class

A PendingIntent encapsulates an Intent and an action that will be carried out when its send method is invoked. Since a PendingIntent is a pending intent, the action is normally an operation that will be invoked some time in the future, most probably by the system. For example, a PendingIntent can be used to construct …

Android Notifications

A notification is a message on the status bar. Unlike a toast, a notification is persistent and will keep showing until it is closed or the device is shut down. A notification is an instance of android.app.Notification. The most convenient way to create a notification is by using a nested class called Builder, which can …

Android AlertDialog

AlertDialog is a window that provides feedback to the user. Unlike a Toast that fades by itself, however, an AlertDialog shows indefinitely until it loses focus. In addition, an AlertDialog can contain up to three buttons and a list of selectable items. A button added to an AlertDialog can be connected to a listener that gets …

Android APK File

An Android application is packaged into an apk file, which is basically a zip file and can be opened using WinZip or a similar program. All applications are signed with a private key. This process sounds hard enough, but thankfully Android Studio takes care of everything. When you run an Android application from inside Android …

Android Manifest file

Every Android application must have a manifest file called AndroidManifest.xml file that describes the application. A sample manifest <?xml version=“1.0” encoding=“utf-8”?> <manifest xmlns:android=“http://schemas.android.com/apk/res/android” package=“com.example.firstapp” > <application android:allowBackup=“true” android:icon=”@drawable/ic_launcher” android:label=”@string/app_name” android:theme=”@style/AppTheme” > <activity android:name=“com.example.firstapp.MainActivity” android:label=”@string/app_name” > <intent-filter> <action android:name=“android.intent.action.MAIN” /> <category android:name=“android.intent.category.LAUNCHER” /> </intent-filter> </activity> </application> </manifest> A manifest file is an XML document with manifest as …

Using Big View Styles in Android

Notifications in the notification drawer appear in two main visual styles, normal view and big view. The big view of a notification only appears when the notification is expanded. This happens when the notification is at the top of the drawer, or the user clicks the notification. Big views were introduced in Android 4.1, and …

Updating Notifications in Android

When you need to issue a notification multiple times for the same type of event, you should avoid making a completely new notification. Instead, you should consider updating a previous notification, either by changing some of its values or by adding to it, or both. The following section describes how to update notifications and also …