228 CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus
Note You have already used a Bundle object to save the current “state bundle” for your Activity subclass,
with the Bundle object named savedInstanceState in your onCreate( ) method call. The Bundle class allows
you to put together “bundles” or collections of variables and data, so it is not complex enough to merit its very
own section in the book. That said, if you are really into bundling things, you can take a detailed look at the
Android Bundle class on the Android developer web site, located at the following URL:
http://developer.android.com/reference/android/os/Bundle.html
The Context object thus contains information about what your application component is doing,
how it is set-up, what resources it uses, and all manner of information regarding that Android
application component, essentially. Whereas the Android Manifest XML definition is used to provide
some of this “global” information to the Android OS when it goes to launch your application,
the Context object provides all of this technical-, systems-, and resources-level info for each of
your application components, “local” information if you will, using the Context object while your
application is actually running.
As I mentioned previously, you only need to know how to use an application component’s Context
(and the this keyword) properly to be successful in the majority of your Android application
programming, design, and development endeavors, so I am not going to spend that much time
delving into the public abstract Context class in this book.
If you’d like to learn more about this Android Context class, you can visit the following Android
developer site URL:
http://developer.android.com/reference/android/content/Context.html
Now we can continue on in our work process for creating a working menu which launches a second
EditGalaxy Activity subclass, and create a RelativeLayout UI design for that Activity, and make it
functional using Events!
Creating Your Second Activity: The EditGalaxy Class
Now that you know what the Java this keyword is, which is used here to pass over the Context
object for your MainActivity.class to the EditGalaxy.class, we can go ahead and mouse-over the
wavy red underline highlight under the reference to the EditGalaxy.class (which does not yet exist),
and select the Create class ‘EditGalaxy’ option, which will give Eclipse the go ahead that it needs
to create this new Java class for you, as shown in Figure 7-10.