Saturday, 13 September 2014

Android forth lecture

 Fourth lecture

A code to make a page as follows:

  • Start a new project and give it a name of your choice.
  • Open res>layout>main.xml
  • Now write the following code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    
    
    <TextView 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:text="User name"
        />
    <EditText 
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"/>
          
     <TextView 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:text="Status"
        />
       <LinearLayout 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal">
     <RadioButton 
         android:layout_height="wrap_content"
         android:layout_width="fill_parent"
         android:text="Male"
         android:layout_weight="1"/>
     <RadioButton 
         android:layout_height="wrap_content"
         android:layout_width="fill_parent"
         android:text="Female"
         android:layout_weight="1"/> 
         </LinearLayout>
         <LinearLayout 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical">
     <TextView 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:text="City"
        />
        <Spinner 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"/>
        
        <TextView 
         android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:text="Course"/>
        </LinearLayout>
        <LinearLayout 
            android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal">
           
        <CheckBox 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="java"
            android:layout_weight="1"/>
        <CheckBox 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="android"
            android:layout_weight="1"/>
</LinearLayout>
<LinearLayout 
     android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical"
    ></LinearLayout>
 <LinearLayout 
            android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal">
        
 <CheckBox 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="iphone"
            android:layout_weight="1"/>
        <CheckBox 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text=".net"
            android:layout_weight="1"/>
        ></LinearLayout>
        <LinearLayout 
            android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal"
        >
        <Button 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="Submit"
             android:layout_weight="1"
            />
        <Button 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="Cancel"
             android:layout_weight="1"
            />
         </LinearLayout>
          </LinearLayout>

  • Method to see the output of the above code is mentioned in the previous post i.e in android third lecture. 


Tuesday, 8 July 2014

Android third lecture



 Third Lecture




Here res is resource in which we have layout. In layout we make the design pattern of our project. And the files in the layout are xml files.
The following are the types of layout:
  • Linear Layout
  • Relative  Layout
  • Grid View
  • List View
  • Custom List
  • Custom Grid
  • Table View
  • Tab View
  • Advance
  • Database
Now here we design our pattern with Linear Layout:
Do the following:
  • First of all Open Eclipse and follow the steps mentioned in *http://androidbydeeksha.blogspot.in/2014/06/android-second-lecture.html
  • Now you are ready to make your program or project.



  • Open res>layout>main.xml
  • Now a screen gets opened.

  • At the bottom of the screen their are two buttons Graphical layout and main.xml as shown below:

  • In Graphical layout we see the pattern we make in our main.xml .
Let's Start with simple project of Login Page by using Linear Layout



Program to make a program as shown in above pictures:

  • Once you have followed the above steps, you are ready to make your program in android.
  • Open the project, suppose you have given the name: SampleAndroidApplication. 

Note: Make sure that you have given the name of your project without space and the alphabet of a particular name should be capital like here it is Sample, Android and Application.






  • Open res>layout>main.xml
  • Click on main.xml
  • Write the coding of layout as follows:
  • Note: we are writing our layout in Linear Layout.


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:orientation="vertical">
         <TextView 
             android:layout_height="wrap_content"
             android:layout_width="fill_parent"
             android:text="User name"/>
         <EditText 
             android:layout_height="wrap_content"
             android:layout_width="fill_parent"/>
            
         <TextView 
             android:layout_height="wrap_content"
             android:layout_width="fill_parent"
             android:text="Password"/>
         <EditText 
             android:layout_height="wrap_content"
             android:layout_width="fill_parent"
             />
            <LinearLayout 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:orientation="horizontal">
            
            <Button 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="Login"
                android:layout_weight="1"
              />
             <Button 
                android:layout_height="wrap_content"
                android:layout_width="fill_parent"
                android:text="Cancel"
                android:layout_weight="1"
               />
              </LinearLayout>
                 </LinearLayout>
                 </LinearLayout>
                   
                 


    • Write the above code in main.xml file and see the layout in Graphical Layout.
    • Now open src file.
    • In src file a package will be made and further a class(java class) will be made.
    • Write the following code in that java class:


    package com.cgc.SampleAndroidApplication;

    import android.app.Activity;
    import android.os.Bundle;

    public class SampleAndroidApplicationActivity extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    }


    • Now the project has been made.
    • Now open your project.

    Steps to open project.

    Emulator


    • Click on Android virtual device manager icon.
    • A screen gets opened.

    •  Click on New.
    • Give name, target(say 2.1) and give size(say 164).
    • Click on Create AVD.
    • Your AVD will be created. Click on the AVD created and then click on start.

    • A box will get opened and click on Scale display to real size.
    • Give screen size (say 7 or 8).
    • Click on Launch.
    • The emulator gets opened.
    • And it will display your project.

    Thursday, 12 June 2014

    Android second lecture

     For making any program in android, their are 3 requirements:

    1) Eclipse
    2) JDK- Java development kit
    3) Android SDK- Software development kit.
    Note-Install all of the above in your system.
    Note- Eclipse screen has two parts- work space and work area.

    For writing a program in android what we need to do is as follows:
    1) Open Eclipse
    2)  Go to File> New> Android Project.


    3) A Screen gets open- as follows:

    4) Now give the name of your project:
    For Example: SampleAndroidApplication
    5) Click on next.
    6) A screen gets opened from where you have to select version-as follows:
    Note-If you select an older version (say- Android 2.1) then it will work on latest one too(like Android 4.0) but the vice versa may  not be possible.
    7) Click on next and the following screen appears:
    8) Write package name here: syntax: com.(name of your company).(name of your project)
    For Example: com.sharable.SampleAndroidApplication
    9) Click on Finish.
    10) You are ready to write your program.

    Sunday, 8 June 2014

    Android first lecture





    About Android




    Answer: Android is a linux based operating system*. 

    History of Android: Android was founded in Palo Alto, California in October 2003 by:
    1) Andy Rubin (co-founder of Danger),
    2) Rich Miner (co-founder of Wildfire Communications, Inc.), 
    3) Nick Sears (once VP at T-Mobile), and
    4) Chris White (headed design and interface development at WebTV)
    Android was founded to develop, in Rubin's words: "smarter mobile devices that are more aware of its owner's location and preferences".

    Description of Android:























         Android 4.4.2 home screen


    Company / developerGoogle
    Open Handset Alliance
    Written inC (core), C++,Java (UI)
    OS familyUnix-like
    Working stateCurrent
    Source modelOpen source and in most devices withproprietarycomponents
    Initial releaseSeptember 23, 2008
    Latest release4.4.3 KitKat / June 2, 2014
    Marketing targetSmartphones
    Tablet computers
    Available inMulti-lingual (46 languages)
    Package managerGoogle Play, APK
    Supported platforms32-bit ARM, MIPS,x86
    Kernel* typeMonolithic (modified Linux kernel)
    UserlandBionic libc, mkshshell, native core utilities with a few fromNetBSD
    Default user interfaceGraphical (Multi-touch)
    LicenseApache License 2.0
    Modified Linux kernelunder GNU GPL v2
    Official websitewww.android.com

    *Operating System: It is an intermediate between hardware and software.


    *Kernel: It is a computer program that manages input/output requests from software & translates them into data processing instructions for the central processing unit(CPU) & other electronic components of a computer.
    Kernel connects the application software to the hardware of a computer.
    When a computer program makes request of a kernel,
    the request is called system call.

        Features of Kernel:




    1. Kernel is a central core of a computer operating system.
    2. Kernel has complete control over everything that occur in the system
    3. It does not interact directly with the user,but rather interacts with the shell and other programs as well as with hardware devices on the system, including the processor,memory & disk drives.
    4. Kernel is the first part of the operating system to load into memory during booting. 



    • Why Android is a linux based operating system?
    Answer: 
    1. Linux is an open source.
    2. It is secure.
    3. Android uses kernel of Linux