Tuesday, September 15, 2015

Basics components in Android applications

Basics components in Android applications



Before getting started with android programming, we need to know some of the basic components of Android applications. These are the buildings blocks of Android applications. These will let us understand Android application from scratch. Let us take a quick look at these components.

Activities
                An activity in Android represents a single screen with user interface. An android application typically consists of several activities.  An activity interacts with the user to do one thing, only ONE, such as Unlock screen, dial a phone, view home etc. An application consists of multiple activities that are loosely bound together. But only one activity can be specified as main activity which is displayed while launching the application. Every time an activity starts previous activity is stopped but the data is preserved.
         For instance an email application will have one activity to display list of new emails, another activity to compose email, another activity for reading emails and so on.

Have a look at activities in detail here

View
             An activity contains views and viewgroups. Views in Andriod are UI components that could be used to build user interface. Examples are buttons, label, and text boxes. One or more views can be grouped together into a ViewGroup. Types of View in android.
  • ·         Basic Views
  • ·         List Views
  • ·         Picker Views
  • ·         Menus
  • ·         Display Views
  • ·         Additional Views
ViewGroup provides a layout where you can order the appearance of views. Android support the following view groups.
·      
  •           LinearLayout
  • ·         TableLayout
  • ·         AbsoluteLayout
  • ·         FrameLayout
  • ·         RelativeLayout
  • ·         ScrollView
Services
                Services are something that does not require user interface. It performs operation without user interaction in the background but does not get initiated without user invocation. Another component such as an activity should invoke. To be more technical, service does not have an independent thread, they make use of the main thread from hosting process. For instance you can download something while you get involved in some other application, where download is a service running in background.

Content Providers
                Android is embedded with SQLite Database where all your data gets stored. Content providers in Android manage data that is being shared by more than one application. Consider a case where your Contacts are stored in centralized repository, so here many applications may require access to it or may even require modifying it. In such cases these applications need to query the centralized repository through content providers, so an application with proper permissions can read or modify the Contacts based on permissions. Content provider is concept evolved to manage common data based on permissions. This is a critical concept that has led to develop in-house android applications in a better way.

Broadcast Receivers
                Broadcast receiver is also a component where you can register for system or application events. Once registered you will be notified about the events. Broadcast originates from the system as well as applications. Instance for broadcast originating from the system is ‘low battery notification’. Application level is, like when you download an mp3 file, Mp3 player gets notified about it, and gets added to player list. For this action to take place, mp3 player has to register for this event. To get detailed information on Broadcast receiver in Android, have a look at this tutorial

Intent
                Intents are messages that allow components to request activities from other components. Consider an activity requires another activity to perform some functionality in such cases communication between activities occurs via Intent

Tuesday, July 21, 2015

Big data

BIG DATA : What is Big Data?

                        Big data is a collection of data sets, it is more large and complex that it becomes difficult to process using on-hand database management tools.
The challenges include capture, data curation, storage, search, sharing, analysis, and visualization.

The trend to larger data sets is due to the additional information derivable from analysis of a single large set of related data, as compared to separate smaller sets with the same total amount of data, allowing correlations to be found to "spot business trends, determine quality of research, prevent diseases, link legal citations, combat crime, and determine real-time roadway traffic conditions.

Big data is the realization of greater business intelligence by storing, processing, and analyzing data that was previously ignored due to the limitations of traditional data management technologies.

Characteristics of Big Data

      Volume  :  Large volumes of data.

      Velocity :  Quickly moving data.

      Variety   : Structured, unstructured, images, etc.

      Veracity : Trust and integrity is a challenge and a must and is important for big data                      just as for traditional relational Databases.
      Value      : Big Data is having no use of unless we can turn it into value.



Three Types of Data:
·        Structured data : Relational data.
·        Semi Structured data : XML data.
·        Unstructured data : Word, PDF, Text, Media Logs.
     The Four Dimensions of Use in Big Data
      The users want to interact with their data,
ü Totality: Users have an increased desire to process and analyze all available data.

ü Exploration: Users apply analytic approaches where the schema is defined in response to the nature of the query.

ü Frequency: Users have a desire to increase the rate of analysis in order to generate more accurate and timely business intelligence.

ü Dependency: Users’ need to balance investment in existing technologies and skills with the adoption of new techniques.
    Tools and System :

}  Hands-on System
·        mySQL
·        MapReduce (YARN)
·        HDFS
·        Hbase
·        DynamoDB
·        Cassandra
·        Memcached
·        Redis
·        MongoDB
·        Pig
·        HIVE
·        Impala
·        Mahout
·        Spark

}  Design Knowledge
·        BigTable
·        Dynamo
·        Dremel
·        Spanner
·        Storm


How to make a First Android Application.

Let Go for Create First Android App.


Hello World Android Application in Eclipse


This post will help you to create and run Hello World Android Project in Eclipse.

        To continue developing your first android application you need to download Android SDK first. You can find this tutorial in Configure Android on PC
  1. Open eclipse, set your working folder then go to File –>New – >Android Application Project.
  2. Here you will have to fill some details which are described clearly below.

                       

    Application Name: Application name should be a user friendly name. This name will be displayed everywhere to identify your application. For example ‘Angry Birds’, ‘Talking Tom’ are some of the application names.
    Project Name: This need not be taken care much as this name is used as an identifier in eclipse. This can be same as your application name or even some other name as developer’s choice but to maintain integrity same name as application name is preferred to use.
    Package Name: Package name is something which has to be given some importance similar to Application name. Android packages follow same conventions as Java packages so this must be a valid Java package name. Package name cannot be changed later. It should have atleast two identifiers.

  3. Then proceed with other default settings, the last pop will be the Activity screen. Now you should be able to view something like the below screen.


  4. Java Source Code

    Let's see the java source file created by the Eclipse IDE:
    File: MainActivity.java
    1. package com.example.HelloWorld;  
    2.   
    3. import android.os.Bundle;  
    4. import android.app.Activity;  
    5. import android.view.Menu;  
    6. import android.widget.TextView;  
    7.   
    8. public class MainActivity extends Activity 
    9. {
    10.   
    11.     @Override  
    12.     protected void onCreate(Bundle savedInstanceState) 
    13. {  
    14.         super.onCreate(savedInstanceState);  
    15.                 
    16.         setContentView(R.layout.activity_main);  
    17.     }  
    18.   
    19.     @Override  
    20.     public boolean onCreateOptionsMenu(Menu menu) 
    21. {
    22.         // Inflate the menu; this adds items to the action bar if it is present.  
    23.         getMenuInflater().inflate(R.menu.activity_main, menu);  
    24.         return true;  
    25.     }  
    26.       
    27. }  
    (1) Activity is a java class that creates and default window on the screen where we can place different components such as Button, EditText, TextView, Spinner etc. It is like the Frame of Java AWT.
    It provides life cycle methods for activity such as onCreate, onStop, OnResume etc.
    (2) The onCreate method is called when Activity class is first created.
    (3) The setContentView(R.layout.activity_main) gives information about our layout resource. Here, our layout resources are defined in activity_main.xml file.
    File: activity_main.xml
    1. <RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"  
    2.     xmlns:tools="http://schemas.android.com/tools"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"  
    5.     tools:context=".MainActivity" >  
    6.   
    7.     <TextView  
    8.         android:layout_width="wrap_content"  
    9.         android:layout_height="wrap_content"  
    10.         android:layout_centerHorizontal="true"  
    11.         android:layout_centerVertical="true"  
    12.         android:text="@string/hello_world" />  
    13.   
    14. </RelativeLayout>  
    As you can see, a textview is created by the framework automatically. But the message for this string is defined in the strings.xml file. The @string/hello_world provides information about the textview message. The value of the attribute hello_world is defined in the strings.xml file.
    File: strings.xml
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <resources>  
    3.   
    4.     <string name="app_name">HelloWorld</string>  
    5.     <string name="hello_world">Hello world!</string>  
    6.     <string name="menu_settings">Settings</string>  
    7.   
    8. </resources>  
    You can change the value of the hello_world attribute from this file.

    Generated R.java file

    It is the auto-generated file that contains IDs for all the resources of res directory. It is generated by aapt(Android Asset Packaging Tool). Whenever you create any component on activity_main, a corresponding ID is created in the R.java file which can be used in the Java Source file later.
    File: R.java
    1. /* AUTO-GENERATED FILE.  DO NOT MODIFY. 
    2.  * 
    3.  * This class was automatically generated by the 
    4.  * aapt tool from the resource data it found.  It 
    5.  * should not be modified by hand. 
    6.  */  
    7.   
    8. package com.example.helloandroid;  
    9.   
    10. public final class R {  
    11.     public static final class attr {  
    12.     }  
    13.     public static final class drawable {  
    14.         public static final int ic_launcher=0x7f020000;  
    15.     }  
    16.     public static final class id {  
    17.         public static final int menu_settings=0x7f070000;  
    18.     }  
    19.     public static final class layout {  
    20.         public static final int activity_main=0x7f030000;  
    21.     }  
    22.     public static final class menu {  
    23.         public static final int activity_main=0x7f060000;  
    24.     }  
    25.     public static final class string {  
    26.         public static final int app_name=0x7f040000;  
    27.         public static final int hello_world=0x7f040001;  
    28.         public static final int menu_settings=0x7f040002;  
    29.     }  
    30.     public static final class style {  
    31.         /**  
    32.         Base application theme, dependent on API level. This theme is replaced 
    33.         by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
    34.      
    35.  
    36.             Theme customizations available in newer API levels can go in 
    37.             res/values-vXX/styles.xml, while customizations related to 
    38.             backward-compatibility can go here. 
    39.          
    40.  
    41.         Base application theme for API 11+. This theme completely replaces 
    42.         AppBaseTheme from res/values/styles.xml on API 11+ devices. 
    43.      
    44.  API 11 theme customizations can go here.  
    45.  
    46.         Base application theme for API 14+. This theme completely replaces 
    47.         AppBaseTheme from BOTH res/values/styles.xml and 
    48.         res/values-v11/styles.xml on API 14+ devices. 
    49.      
    50.  API 14 theme customizations can go here.  
    51.          */  
    52.         public static final int AppBaseTheme=0x7f050000;  
    53.         /**  Application theme.  
    54.  All customizations that are NOT specific to a particular API-level can go here.  
    55.          */  
    56.         public static final int AppTheme=0x7f050001;  
    57.     }  
    58. }  

    APK File

    An apk file is created by the framework automatically. If you want to run the android application on the mobile, transfer and install it.

    Resources

    It contains resource files including activity_main, strings, styles etc.

    Manifest file

    It contains information about package including components such as activities, services, content providers etc.
    For more information about manifest file visit here: Android Manifest.xml file.
  5. Application Name is HelloWorld. To run and view this application in Android Emulator Right click on your project and click RunAs Android Application as shown below

                           

  6. Now you must be able to see you application in Android emulator as shown below. You need to unlock the virtual phone to view your application. Or if you face any database connectivity issues it must be due to your firewall settings or Antivirus. If not you will be able to see the below screen


    Now we are done with basic Hello world application in Eclipse.