Tuesday, 27 January 2015

Before Creating A New Application the basic things to be known !



              When you create android application the following folders are created in the package explorer in eclipse which are as follows:
src: Contains the .java source files for your project. You write the code for your application in this file. This file is available under the package name for your project.
gen This folder contains the R.java file. It is compiler-generated file that references all the resources found in your project. You should not modify this file.
Android 4.0 library: This folder contains android.jar file, which contains all the class libraries needed for an Android application.
assets: This folder contains all the information about HTML file, text files, databases, etc.
bin: It contains the .apk file (Android Package Key) that is generated by the ADT during the build process. An .apk file is the application binary file. It contains everything needed to run an Android application.
res: This folder contains all the resource file that is used by android application. It contains sub-folders as: drawable, menu, layout, and values etc.

AndroidManifest.xmlfile in detail.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.teja" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
<activity android:name="com.example.teja.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>
  • It contains the package name of the application.
  • The version code of the application is 1.This value is used to identify the version number of your application.
  • The version name of the application is 1.0
  • The android:minSdkVersion attribute of the element defines the minimum version of the OS on which the application will run.
  • ic_launcher.png is the default image that located in the drawable folders.
  • app_name defines the name of applicationand available in the strings.xml file.
  • It also contains the information about the activity. Its name is same as the application name.

     Android Activities :

                Activity provides the user interface. When you create an android application in eclipse through the wizard it asks you the name of the activity. Default name is MainActivity. You can provide any name according to the need. Basically it is a class (MainActivity) that is inherited automatically from Activity class. Mostly, applications have oneor more activities; and the main purpose of an activity is to interact with the user. Activity goes through a number of stages, known as an activity’s life cycle.
                  An activity is implemented as a subclass of Activity class as follows: 
        public class MainActivity extends Activity {
                      } 

 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 {
                                                               }

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 {
                                         }

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 {
                                             } 

No comments:

Post a Comment