Showing posts with label basic terms in android. Show all posts
Showing posts with label basic terms in android. Show all posts

Wednesday, June 20, 2012

Fundamental Android- For Beginner (Tutorial 1)

Fundamental Android- For Beginner (Tutorial 1)

Hii Friends this is the first tutorial in which I will explain you new paradigms introduced by the Android platform for developers. 

This part will just explain you the fundamental block of the android and latter part of the tutorial will explain you the high standard programming in the andoid, more to drive home to concept than to show any great programming skills.

Android is working on the  four building/ blocks. From the perspective of the developer we can categories as follows:-
1. Activities
2. Services
3. Broadcast Receivers
4. Content Providers.

The Communication between the above mentioned components is through :-
1. Intents
2. Intent Filters

The user Interface for interaction is called:- 
1. Views
2. Notifications

Get a Brief look of above mentioned syntax's:- 

Activity is the basic building block of every visible android application. It provides the means to render a UI. Every screen in an application is an activity by itself. Though they work together to present an application sequence, each activity is an independent entity. Any application can not be imagine without an activity. An activity can also be stated as a page which is shown at the front end when the application is running.



Service is another building block of android applications which does not provide a UI. It is a program that can run in the background for an indefinite period. It is a very powerful feature in the android which is used to do any process in the background without intervention of the user. Like login to any application in background and show some other activity at the front end.

Broadcast Receiver is yet another type of component that can receive and respond to any broadcast announcements. Means if you have used the android phones or tablets then you have may times seen that many notification is coming on the notification bar these notification is get by the Broadcast receiver and shown at the front end.


Content Providers are a separate league of components that expose a specific set of data to applications. Means its a set of data which you used to be process and want to show to the user.


While the understanding and knowledge of these four components is good enough to start development, the knowledge of the means of communication between the components is also essential. The platform designers have introduced a new concept of communication through intents and intent filters. Intents are used for the communication between ll the above component stated they passed the data between each component with the help of some variable.



Intents are the messages that passed between the components, So we can say that it is very similar to the API where the API is used to pass data and get some response as same here it  passes the data with the help of some variable and nothing other more stress is needed there to accomplish this task.
However, the fundamental differences between API calls and intents' way of invoking components is
1. API calls are synchronous while intent-based invocation is asynchronous (mostly)
2. API calls are bound at compile time while intent-based calls are run-time bound (mostly)



Intents are of two types Implicit intents and explicit intents. Both will explain in the later posts.


Intent is a bundle of information, a passive data structure that holds an abstract description of the operation to be performed. (or in the case of broadcasts, a description of an event that has happened and is being announced).

Tuesday, June 19, 2012

Explicit Intent | Android Tutorial for Beginners

Explicit Intent I have described  intents earlier. Here we will discuss about intents, Intents are the methods to make a communication between two activities. means they used to pass data from one activity to other with the help of some variables.

There are 2 types of intents that Android understands.
1. Explicit Intent
2. Implicit Intent

In an Explicit intent, you actually specify the activity that is required to respond to the intent. In other words, you explicitly designate the target component(Activity). This is typically used for application internal messages.
Like we have to pass data from one activity to other activity to accomplish certain processing we used explicit intents.

In an Implicit intent (the main power of the android design), you just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, you do not declare the target component and hence is typically used for activating components of other applications seamlessly.


Now to explain intents in more detail you can download my example from here.


        Button invokeIntent = (Button)findViewById(R.id.invokeintent);
       
invokeIntent.setOnClickListener(new OnClickListener() {
        

        
public void onClick(View v) {
        
Intent explicitIntent = new Intent(InvokingActivity.this,InvokedActivity.class);
         startActivity(explicitIntent);
        
}
        });

 Note: Here the InvokingActivity activity this class have the layout main.xml and the  InvokedActivity this activity have the InvokedActivity.xml file for there layout. both of the layout you can make by using eclipse.

 In the next part of the series, we will see how to work with implicit intents which also needs us to understand intent-filters.