DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Pre-Packaged Applications | Android Tutorial for Beginners (Part 4)

Pre-Packaged Applications | Android Tutorial for Beginners (Part 4)

Sai Geetha M N user avatar by
Sai Geetha M N
·
May. 23, 11 · Interview
Like (0)
Save
Tweet
Share
3.13K Views

Join the DZone community and get the full member experience.

Join For Free
There are many applications that can pre-packaged into the android platform that can be reused by custom built applications because of the power of the android design that is based on implicit intents.(See part 3 of this series for implicit intents).

Here we will explore how to invoke the pre-packaged applications from our own through implicit intents. Note that in none of the snippets below, we actually call the pre-packaged or system applications. We just declare intents and pass them to an activity while starting the activity through startActivity() method. However, for each of these intents, the android platform finds the most befitting activity and invokes the same:

1. Call a number

      Intent callNumber = new Intent();
      callNumber.setAction(android.content.Intent.ACTION_CALL);
      callNumber.setData(Uri.parse("tel:9440012345"));
      startActivity(callNumber);
This will call the number 9440012345. For calling custom numbers, you could provide the user with a edit text field from which you can access the number and set it to the data above instead of a hard-coded number.

2. Browse the web for a given url:

      Intent searchGivenText = new Intent(Intent.ACTION_WEB_SEARCH);
      searchGivenText.putExtra(SearchManager.QUERY, "Android Examples);
      startActivity(searchGivenText);

This will invoke the Google search engine to search the string "Android Examples" and return the results to you. This too can be generalized to accept a string from the user and set to the intent before starting the activity.

3.  View google maps for a given location

      Intent searchAddress = new Intent(Intent.ACTION_VIEW, 
      Uri.parse("geo:0,0?q=Bangalore"));
      startActivity(searchAddress);
This shows the location of Bangalore on Google Maps.

4. View Contacts on the phone

      Intent contacts = new Intent();
      contacts.setAction(android.content.Intent.ACTION_VIEW);
      contacts.setData(People.CONTENT_URI);
      startActivity(contacts);

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.

--------
Updated on March 31 2010:

The above example uses Android SDK 1.5 From SDK 1.6 and above, the Contact.People class has been deprecated and we need to use the ContactsContract class. So the line in code
     

contacts.setData(People.CONTENT_URI);

has to be replaced by 
            

 contacts.setData(ContactsContract.Contacts.CONTENT_URI);


Here is the complete source code that has been tested with Android SDK 2.1

 

Source:  Pre-Packaged Applications | Android Developer Tutorial (Part 4)


application Android (robot)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java REST API Frameworks
  • A Beginner's Guide to Infrastructure as Code
  • Custom Validators in Quarkus
  • Secure APIs: Best Practices and Measures

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: