Azare Puasa

Note To Self

Connect

  • Facebook
  • Twitter
  • Linkedin
  • Home
  • Blog
  • My Fave Videos
  • Success Strategies
  • Achievements
  • Baking For Men
  • Matters of the Heart
  • Linux
  • WordPress
  • Programming
  • Book Review
  • Others

Android Intent

Posted on June 5, 2010 by Azare Puasa

Intent is one of the things i need to master. So what must i know about Intent? Basically, I have to know what it is and how to use.

What is an Intent?

In simple terms, an Intent in Android is a way to pass certain information from one activity to another activity. There are 2 main categories of Intent:

  • Activity Action Intents: Pass information to a single activity outside the application. e.g. “WEB_SEARCH_ACTION” opens Google search or another web page if specified.
  • Broadcast Action Intents: Sent out information to multiple activity. e.g. “MEDIA_EJECT_ACTION” is sent when ejection action has been initiated on an SD memory card.

For an intent from an activity to work, it requires 2 other mechanism,

  • Intent Receiver: sort of a mailbox for the activity. Every activity has a receiver and it has a list of intents that it accepts and process.
  • Intent Filters: describes the type of intents it will receive and also outlines the data format the Intent accepted by the activity .

How do i use an Intent?

1. Import the appropriate package.

  • android.content.Intent

2. Create an Intent object

Intent <intent_name> = new Intent(<Android_Intent>, <data>)

  • <intent_name>: name of the my intent object
  • <Android_Intent>: Intent name.
  • <data>: data to be sent out by the intent

e.g. creating a DIAL_ACTION Intent

Intent DialIntent = new Intent(Intent.DIAL_ACTION, Uri.parse(“tel:5551212”));

Note: In this case, need to import android.net.Uri

3. Use setLaunchFlags() of the Intent object i just created to specify to android the type of activity to launch.

e.g. DialIntent.setLaunchFlags(Intent.NEW_TASK-LAUNCH);

4. Lastly, launch the activity using startActivity()

e.g. startActivity(DialIntent);

Reference:

1. Android A Programmer’s Guide, Jerome (J.F) DiMarzio

(ISBN 978-0-07-159988-7)

About Azare

He is a full-time software developer and an Internet Infopreneur. He has a decade of experience developing Installshield Installscript. After getting his RHCE, he has short stint as a Redhat System Engineer. His work now involves coding Java language. In his free time, how dabbles with Wordpress website development and SEO. He loves archery and golf.

Contact Azare

Step 1 of 2

50%

Azare’s bookshelf: read

Click Millionaires: Work Less, Live More with an Internet Business You Love
Outsource Smart: Be Your Own Boss... Without Letting Your Business Be the Boss of You
How I Made My First Million on the Internet and How You Can Too!: The Complete Insider's Guide to Making Millions with Your Internet Business
Winning The Game of Life!
The $100 Startup: Reinvent the Way You Make a Living, Do What You Love, and Create a New Future
The Laptop Millionaire
Speed Reading in a Week: Teach Yourself
The 4-Hour Workweek
Think and Grow Rich
The Monk and the Riddle: The Education of a Silicon Valley Entrepreneur
Success as an Introvert for Dummies
The Clean Coder: A Code of Conduct for Professional Programmers
Be Rich and Happy
Celebrating Failure: The Power of Taking Risks, Making Mistakes, and Thinking Big
The Art of Readable Code
A Gift to My Children: A Father's Lessons for Life and Investing
Zero to One: Notes on Startups, or How to Build the Future

Copyright ©2025 · Azare Puasa - All Rights Are Reserved · Terms & Conditions· Privacy Policy

Copyright © 2025 · Azare Puasa on Genesis Framework · WordPress · Log in