Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1

Creating Locatr


Creating Locatr


Now to get started. In Android Studio, create a new project called Locatr. Create an empty activity and
name it LocatrActivity. As you have for your other apps, set your minimum SDK to 19 and copy in
SingleFragmentActivity.java and activity_fragment.xml.


You will also want some additional code from PhotoGallery. You will be querying Flickr again,
so having your old query code will be handy. Open up your PhotoGallery solution (anything after
Chapter 26 will do), select FlickrFetchr.java and GalleryItem.java, and right-click to copy them.
Then paste them into your Java code area in Locatr.


In a minute, you will get started on building out your UI. If you are using an emulator, though, read
this next section so that you can test all the code you are about to write. If you are not, feel free to skip
ahead to the section called Building Out Locatr.


Play Services and Location Testing on Emulators


If you are using an AVD emulator, you must first make sure that your emulator images are up to date.


To do that, open up your SDK Manager (Tools → Android → SDK Manager). Go down to the version
of Android that you plan to use for your emulator and ensure that the Google APIs System Images
are both installed and up to date (Figure 33.2). If an update is available, click the button to install the
update and wait until it is ready to go before continuing.


Figure 33.2  Ensuring your emulator is up to date

Free download pdf