Saturday, June 23, 2012

Pre-Packaged Applications | Android Tutorial for Beginners

There are many applications that are pre-packaged in the android platform that can be reused by the other custom applications. As we have stated in the previous  part 3. Implicit intents there we have provided the example of these types of one application related to contact application of android.

In this part of tutorial we will explore that how we can use the pre-packaged applications using impliocit intents. In these types of application we will just call the pre-packaged application using intents and pass them to the activity and after then we will start our activity with the startActivity() method. However, for each of these intents, the platform find the most befitting activity and invoke the same:

1. Call a number(Dial a number via application)
      Intent callNumber = new Intent();

This will call the number 123456789.If you want to call any number you want then you have to just add a edit text control then pass the desired value to the Uri.parse() method then it will dial your specified number.

2. Browse the web for a given url:

      Intent searchText = new Intent(Intent.ACTION_WEB_SEARCH);
      searchText.putExtra(SearchManager.QUERY, "Android Demo);

This will start the google search  engine to search the specified string "Android Demo" and the get back the result on the screen. here the same thing as above specified in the dialed number application you can define a edit text control the pass the desired string to the appropiate space in the putExtra() method then the same result will show on the screen.

3.  View google maps for a given location(find out any location)

      Intent searchLocation = new Intent(Intent.ACTION_VIEW, 

This will show the "India" location on the Google map. You can repeat the smae method for the edit text to search your desired location.

4. View Contacts on the phone(Navigate to view contacts)

Intent contacts = new Intent();

I have created an Android eclipse project which showcases all of these examples by taking inputs from the end user. You can access the same here.

No comments:

Post a Comment