Android Application Developement Short Notes

1). Android is an open source and Linux-based Operating System for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.

2). Android applications are usually developed in the Java language using the Android Software Development Kit.

3). Once developed, Android applications can be packaged easily and sold out either through a store such as Google Play or the Amazon Appstore.

4). Window > AVD Manager> which will launch Android AVD Manager. Use New button to create a new Android Virtual Device and enter the following information, before clicking Create AVD button.

5). Android operating system is a stack of software components which is roughly divided into five sections :
	Application >> Application Framework >> Libraries >> Android Runtime >> Linux Kernal

6). At the bottom of the layers is Linux - Linux 2.6 with approximately 115 patches.This provides basic system functionality like process management, memory management, device management like camera, keypad, display etc. Also, the kernel handles all the things that Linux is really good at such as networking and a vast array of device drivers, which take the pain out of interfacing to peripheral hardware.

7). Android Runtime provides a key component called Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed and optimized for Android.

8). Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest file AndroidManifest.xml that describes each component of the application and how they interact.

9). There are following four main components that can be used within an Android application:
	Activities 	: 	They dictate the UI and handle the user interaction to the smartphone screen
	Services 	:	They handle background processing associated with an application.
	Broadcast Receivers :	They handle communication between Android OS and applications.
	Content Providers   :	They handle data and database management issues.

10). Activities : An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. If an application has more than one activity, then one of them should be marked as the activity that is presented when the application is launched.
	An activity is implemented as a subclass of Activity class as follows:
	public class MainActivity extends Activity {

11). Services : A service is a component that runs in the background to perform long-running operations. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.
	A service is implemented as a subclass of Service class as follows:
	public class MyService extends Service {

12). Broadcast Receivers : Broadcast Receivers simply respond to broadcast messages from other applications or from the system. For
example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action.
	A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each message is broadcasted as an Intent object.
	public class MyReceiver extends BroadcastReceiver {


13). Content Providers : A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. The data may be stored in the file system, the database or somewhere else entirely.
	A content provider is implemented as a subclass of ContentProvider class and must implement a standard set of APIs that enable other applications to perform transactions.

	public class MyContentProvider extends ContentProvider {

14). Additional Components :
	Fragments	: Represents a behavior or a portion of user interface in an Activity.
	Views 		: UI elements that are drawn onscreen including buttons, lists forms etc.
	Layouts 	: View hierarchies that control screen format and appearance of the views.
	Intents 	: Messages wiring components together.
	Resources 	: External elements, such as strings, constants and drawables pictures.
	Manifest 	: Configuration file for the application.

15). Folder, File & Description :
	src 	: This contains the .java source files for your project. By default, it includes an source file 
		  having an activity class that runs when your app is launched using the app icon.

	gen	: This contains the .R file, a compiler-generated file that references all the resources found in your project. You 
		  should not modify this file.

	bin	: This folder contains the Android package files .apk built by the ADT during the build process and everything else 
		  needed to run an Android application.
	res/drawable-hdpi	: This is a directory for drawable objects that are designed for high-density screens.
	res/layout : This is a directory for files that define your app's user interface.

	res/values : This is a directory for other various XML files that contain a collection of resources, such as strings and colors

	AndroidManifest.xml : This is the manifest file which describes the fundamental characteristics of the app and defines each of 
			      its components.

16). The main activity code is a Java file This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application.

17). The onCreate() method is one of many methods that are fired when an activity is loaded.

18). Whatever component you develop as a part of your application, you must declare all its components in a manifest file called AndroidManifest.xml which ressides at the root of the application project directory. This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS.

	18.1). 	Here <application>...</application> tags enclosed the components related to the application. Attributeandroid:icon 			will point to the application icon available under res/drawable-hdpi. The application uses the image named 
		ic_launcher.png located in the drawable folders

	18.2).  The <activity> tag is used to specify an activity and android:name attribute specifies the fully qualified class name
		of the Activity subclass and the android:label attributes specifies a string to use as the label for the activity. You 
		can specify multiple activities using <activity> tags.

	18.3). 	The action for the intent filter is named android.intent.action.MAIN to indicate that this activity serves as the entry
		point for the application. The category for the intent-filter is namedandroid.intent.category.LAUNCHER to indicate
		that the application can be launched from the device's launcher icon.

19). Following is the list of tags which you will use in your manifest file to specify different Android application components:
	a). <activity> elements for activities
	b). <service> elements for services
	c). <receiver> elements for broadcast receivers
	d). <provider> elements for content providers

20). The strings.xml file is located in the res/values folder and it contains all the text that your application uses. For example, the names of buttons, labels, default text, and similar types of strings go into this file. This file is responsible for their textual content. For example, a default strings file will look like as following file:
	Code for the String.xml :
		<string name="app_name">HelloWorld</string>
		<string name="hello_world">Hello world!</string>
		<string name="menu_settings">Settings</string>
		<string name="title_activity_main">MainActivity</string>

21). The gen/com.example.helloworld/ file is the glue between the activity Java files and the resources like strings.xml. It is an automatically generated file and you should not modify the content of the file.

22). The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. 

23). Directories of res folder:
	anim/	:	XML files that define property animations. They are saved in res/anim/ folder and accessed from the R.anim 

	color/ 	:	XML files that define a state list of colors. They are saved in res/color/ and accessed from the R.color class.
	drawable/ : 	Image files like .png, .jpg, .gif or XML files that are compiled into bitmaps, state lists, shapes, animation 				drawables. They are saved in res/drawable/ and accessed from the R.drawable class.

	layout/ :	XML files that define a user interface layout. They are saved in res/layout/ and accessed from the R.layout 
	menu/ 	:	XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu. They are saved in 				res/menu/ and accessed from class.

	raw/ 	:	Arbitrary files to save in their raw form. You need to callResources.openRawResource() with the resource ID, 				which is R.raw.filename to open such raw files.
	values/ :	XML files that contain simple values, such as strings, integers, and colors. For example, here are some 
			filename conventions for resources you can create in this directory:
				a). arrays.xml for resource arrays, and accessed from the R.array class.
				b). integers.xml for resource integers, and accessed from the R.integerclass.
				c). bools.xml for resource boolean, and accessed from the R.bool class.
				d). colors.xml for color values, and accessed from the R.color class.
				e). dimens.xml for dimension values, and accessed from the R.dimen class.
				f). strings.xml for string values, and accessed from the R.string class.
				g). styles.xml for styles, and accessed from the class

24). xml/ : Arbitrary XML files that can be read at runtime by calling Resources.getXML(). You can save various configuration files here which will be used at run time.

25). Alternative Resources : Your application should provide alternative resources to support specific device configurations. For example, you should include alternative drawable resources ( ie.images ) for different screen resolution and alternative string resources for different languages. At runtime, Android detects the current device configuration and loads the appropriate resources for your application.

	For example :
	drawable/icon.png, background.png
	drawable-hdpi/icon.png, background.png
	drawable-ar/icon.png, background.png

26). ACCESSING RESOURCES IN CODE : When your Android application is compiled, a R class gets generated, which contains resource IDs for all the resources available in your res/ directory. You can use R class to access that resource using sub-directory and resource name or directly resource ID.
	EXAMPLE: (To access res/drawable/myimage.png and set an ImageView you will use following code:)
	ImageView imageView = (ImageView) findViewById(;

27). Example :
	<?xml version="1.0" encoding="utf-8"?>
		<string name="hello">Hello, World!</string>

	From Code:
	TextView msgTextView = (TextView) findViewById(;

28). Example :
	<?xml version="1.0" encoding="utf-8"?>
		<color name="opaque_red">#f00</color>
		<string name="hello">Hello!</string>

	From Code:
	<?xml version="1.0" encoding="utf-8"?>
	<EditText xmlns:android=""
	android:text="@string/hello" />

29). An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. If an application has more than one activity, then one of them should be marked as the activity that is presented when the application is launched.

30). Android system initiates its program with in anActivity starting with a call on onCreate() callback method. 

31). Example of activity callback funtions :
	onResume(), onPause(), onStop(), onStart(), onCreate(), onDestroy(), onRestart()

32). The Activity class defines the following callbacks i.e. events.
	onCreate() 	: This is the first callback and called when the activity is first created.
	onStart() 	: This callback is called when the activity becomes visible to the user.
	onResume() 	: This is called when the user starts interacting with the application.
	onPause() 	: The paused activity does not receive user input and cannot execute any code and called when the current 
			  activity is being paused and the previous activity is being resumed.
	onStop() 	: This callback is called when the activity is no longer visible.
	onDestroy() 	: This callback is called before the activity is destroyed by the system.
	onRestart() 	: This callback is called when the activity restarts after stopping it.

33). An application can have one or more activities without any restrictions. Every activity you define for your application must be declared in your AndroidManifest.xml file and the main activity for your app must be declared in the manifest with an <intent-filter> that includes the MAIN action and LAUNCHER category.
		<action android:name="android.intent.action.MAIN" />
		<category android:name="android.intent.category.LAUNCHER"/>

34). A service is a component that runs in the background to perform long-running operations without needing to interact with the user. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity. 

35). Types of services :
	a). Started : A service is started when an application component, such as an activity, starts it by calling startService(). 		    Once started, a service can run in the background indefinitely, even if the component that started it is destroyed.

	b). Bound : A service is bound when an application component binds to it by callingbindService(). A bound service offers a 		    client-server interface that allows components to interact with the service, send requests, get results, and even do so 		    across processes with interprocess communication (IPC).

36). Callbacks of Service Class :
	a). onStartCommand()  : The system calls this method when another component, such as an activity, requests that the service be 		started, by calling startService(). If you implement this method, it is your responsibility to stop the service when its work 		is done, by calling stopSelf() or stopService() methods.
37). Content Providers : A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network.

38). Content providers let you centralize content in one place and have many different applications access it as needed. A content provider behaves very much like a database where you can query it, edit its content, as well as add or delete content usingg insert(), update(), delete(), and query() methods. In most cases this data is stored in an SQlite database.

39). Content URIs : To query a content provider, you specify the query string in the form of a URI which has following format:
	Here is the detaial of various parts of the URI:
	prefix		:  This is always set to content://

	authority	:  This specifies the name of the content provider, for example contacts, browser etc. For third-party content 				   providers, this could be the fully qualified name, such ascom.tutorialspoint.statusprovider.

	data_type	:  This indicates the type of data that this particular provider provides. For example, if you are getting all 				   the contacts from the Contacts content provider, then the data path would be people and URI would look like 				   this content://contacts/people

	Id		: This specifies the specific record requested. For example, if you are looking for contact number 5 in the 
			  Contacts content provider then URI would look like thiscontent://contacts/people/5.

40). Create Content Provider : This involves number of simple steps to create your own content provider.
	a). First of all you need to create a Content Provider class that extends the ContentProviderbaseclass.

	b). Second, you need to define your content provider URI address which will be used to access the content.

	c). Next you will need to create your own database to keep the content. Usually, Android uses SQLite database and framework 		    needs to override onCreate() method which will use SQLite Open Helper method to create or open the provider's databse. 		    When your application is launched, theonCreate() handler of each of its Content Providers is called on the main 		    application thread.

	d). Next you will have to implement Content Provider queries to perform different database specific operations.
	e). Finally register your Content Provider in your acitivity file using <provider> tag.

41). Here is the list of methods which you need to override in Content Provider class to have your Content Provider working:
	a). onCreate() 	: This method is called when the provider is started.
	b). query() 	: This method receives a request from a client. The result is returned as a Cursor object.
	c). insert()	: This method inserts a new record into the content provider.
	d). delete() 	: This method deletes an existing record from the content provider.
	e). update()	: This method updates an existing record from the content provider.
	f). getType()   : This method returns the MIME type of the data at the given URI.

Install Cruise Control and PHP Under Control

- Download the Latest version of CruiseControl

- Make the clone of PHP Under Control
	git clone git://
- php phpUnderControl/bin/phpuc(.php|.bat) install /path/to/cruisecontrol
- Give the 755 permission to file under cruisecontrol folder
	sudo chmod 755 ./
- Run the Commad :
	sudo ./
- Set the JAVA_HOME according your java location.

Install Android Studio on Ubuntu

Steps to Install the Android Studion on Ubuntu
  • Download the Android Studio from
  • Extract it sudo tar -zxvf android-studio-bundle-133.970939-linux.tgz -C /opt/
To create the desktop Icon :
  • sudo gedit /usr/share/applications/android-studio.desktop
  • Add the code:
[Desktop Entry]
Name=Android Studio
Comment=Develop with pleasure!

To install the JDK 7 on Ubuntu:
  • sudo add-apt-repository ppa:webupd8team/java
  • sudo apt-get update
  • sudo apt-get install oracle-java7-installer

PHP Code Formatter Setting for Zend Studio

Enable PSR2 Library in Zend Studio :
Windows >> Preferences >> PHP >> Code Style >> Formatter
Select PSR2 from Active Profile dropdown.

Installing Code sniffer
sudo wget
sudo php go-pear.phar
sudo /usr/bin/pear install PHP_CodeSniffer

Check code :
phpcs --standard=Zend --report=summary folder_path/ >summay.txt
phpcs --standard=Zend --report=full folder_path/ >fullreport.txt

Git Tag

Cloning the branch or tag:
git clone --branch <tag_name> <repo_url>

Git pull for a specific tag :
git pull origin <tag_name>

Git checkout for a specific tag :
git checkout <tag_name>

Git pushing the tag:
git push --tags

Installing node.js latest version and express framework

Run the following commands to install node.js and express framework in Ubuntu
  • sudo apt-get update
  • sudo apt-get install python-software-properties python g++ make
  • sudo add-apt-repository ppa:chris-lea/node.js
  • sudo apt-get update
  • sudo apt-get install nodejs
  • sudo npm install -g express

Find and Replace Linux Command

Find and Replace Linux Command
grep -rl “search_word” vendor/* -R | xargs sed -i ‘s/search_word/replace_word/g’

Install ZFTool for ZF2 Framework Project

  1. Download the ZFTool
  2. Extract it into “vendor/ZFTool” folder
  3. Now run the command “php vendor/ZFTool/zf.php”
  4. Above command will list the help for ZFTool
All the  command will be listed for using the ZFTool.
Some important ZFTools commands:
  1. zf.php modules : For listing the modules
  2. zf.php version : For getting the version of ZF2
  3. zf.php config list list all configuration options
  4. zf.php config get <name> display a single config value, i.e. “config get”
  5. zf.php config set <name> <value> set a single config value (use only to change scalar values)
  6. zf.php create project <path> create a skeleton application
  7. zf.php create module <name> [<path>] create a module
  8. zf.php create controller <name> <module> [<path>] create a controller in module
  9. zf.php create action <name> <controllerName> <module> [<path>] create an action in a controller
  10. zf.php classmap generate <directory> <classmap file> [--append|-a] [--overwrite|-w]
  11. zf.php install zf <path> [<version>]
Note : For running the above commands fire it from root project directory of ZF “php vendor/ZFTool/zf.php”

Install Zendframe work2 on Ubuntu by Composer

Install the composer :
curl -sS | php

Now install the Zendframe work:
php composer.phar create-project -sdev --repository-url="" zendframework/skeleton-application /path/to/install/zendframework

If you got the "*.so" error then follow the below steps to solve it:
Run the command grep -Hrv ";" /etc/php5 | grep -i "extension="
Opent he *.ini files and comment the modules which is generating the errors
Now access the project :

Hack the Ubuntu Password

Steps to boot in single user mode in Ubuntu 12.04:

Step 1: When you start your system, press “shift” key continuously to get the grub loader screen.

Step 2: In Grub 2 menu, select the menu with Linux highlighted.

Step3: Press ‘e’ to edit the grub2 menu.

Step 4:  Move the cursor to the line that starts with “linux /boot/vmlinuz-3.2.0-23-generice-pae”.

Step 5: Change the content “ro quiet spalsh $vt_handoff” To “rw init=/bin/bash”.

Step 6: Press “Ctrl+x” to continue boot to in single user mode.

Step 7: Now you will get prompt of the root user.

Step 8: Change root user password,
# passwd root

Step 9: Now sync and reboot the system i.e.
# sync
# reboot -f

I hope, above steps are helpful to change the root user password in single user mode.

Powered by WordPress | Designed by: My Touch 4G
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.