A (175)

(Tuis.) #1

520 CHAPTER 14: Android Content Providers: Providing Data to Applications


Next, add in the android:name parameter, and reference your ContactGalaxy class by using your
package name as the path resource qualifier. This will give the parameter the full resource path with
which to reference the new class.


Your final tag XML markup with both of these configuration parameters installed inside of
it should look like the following, as shown in Figure 14-6:


<activity android:label="@string/contact_galaxy"
android:name="absolute.beginners.hellouniverse.ContactGalaxy" />


Next you are going to create your MenuItem, which will allow your users to access this
ContactGalaxy Activity subclass and its database functions using a menu title of “Contact Galaxy
Ruler.” This enables the application users to contact the emperor of each galaxy in their application
directly. Contacting the emperors of each galaxy represents the ultimate in social media these days,
as you might well imagine. Emphasis is on the word “imagine” here, of course. You will create a


constant, and reference it in the new MenuItem object XML definition, and finally, you will
use an Intent object to access the MenuItem object inside of your switch-case statement, which is
inside your MainActivity.java class Menu object event listening structure. Let’s get started!

Adding a Contact Galaxy Ruler Item to the Menu


Right-click on your strings.xml file in your /res/values folder and Open it for editing. Add a
tag with the name contact_galaxy and a data value of Contact Galaxy Ruler, as shown
in Figure 14-7.


Figure 14-6. Add an child tag after the child tag for the new ContactGalaxy activity subclass

Free download pdf