Intents are just what they sound like, a way to declare to the Android Framework what you intend to do. This can be starting a specific activity, or it can be just asking Android to find some program that can perform an action (whether or not you know what programs are available). We can also go in the other direction, and determine what actions are available to us for a particular piece of content. We are going to cover each of these topics in this article.
In this article I showed you how to open a specific activity using the startActivity method and an Intent that specifies a class. This is just the tip of the iceberg when it comes to using intents.
Here is the basic activity I am going to be using for the rest of this article. At this point, it is just a ListActivity which is going to reference the different examples we are going to see.
package com.learnandroid.intents; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListAdapter; public class UsingIntentsActivity extends ListActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListAdapter adapter = createAdapter(); setListAdapter(adapter); } protected ListAdapter createAdapter() { String[] listValues = new String[] { "The Activity You Know", "The URI You Know", "When You Just Don't Know" }; // Create a simple array adapter (of type string) with the test values ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 , listValues); return adapter; } } |
Next: The Activity You Know
{ 6 } Comments
i am new to android can you please explain what is onclicklistner (not what is does) and why we use View.onclicklistner and what is view there
very useful, thaks..
wow…amazing…you give simple and easy look to android layout…..
thank you very much
great post, very useful for beginers
Will you accept guest post content?
Sure, I would be willing to accept a guest post. Basically, my criteria would be that I should be able to open Eclipse, go through your tutorial step by step, and have it work without needed to figure out any extra stuff.
Basically, I started this website with a friend (he wrote the lots of lists post). I was very gung ho about it… and then I found myself going through a divorce. I’ve kicked around the idea of starting to do tutorials again, and would be glad to have new content on here.
Post a Comment