Book Image

Learning Android Google Maps

Book Image

Learning Android Google Maps

Overview of this book

This book helps you to overcome the most common problems faced by users and helps you create a successful map application without any hassle. The book starts with a brief description of how to set up an environment and obtain an API key to create your map application. This book will teach you about adding markers, overlays, and information windows to the map in detail. You will then dive deep into customizing various types of maps and working with location data and Google Street view. By the end of this book, you will be able to create succinct map applications in Android using Google maps efficiently.
Table of Contents (18 chapters)
Learning Android Google Maps
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Exploring Android Studio


Let's see how we can do some basic things with the official Android Studio IDE. You can change the appearance of Android Studio as you wish. It has some inbuilt themes like:

  • The IntelliJ theme, which is the default theme

  • The Dracula theme, which is a dark cool theme

You can change the theme by navigating to File | Settings | Appearance.

Creating a sample application

Let's create our first sample Android application using Android Studio.

  1. To create a new project, select File | New Project. The following window will appear:

    The wizard for creating a new project

  2. Enter the values in Application name:, Company Domain:, and Package name:. Then, select the project location.

  3. In the next screen, you need to select the minimum SDK version that your application supports. Targeting your application for a lower SDK version ensures that your application runs on a maximum number of devices. As of now, KitKat has a market share of 34 percent.

  4. In the next screen, you need to select an activity template. This template helps you to simplify the task. For our sample application, select Blank Activity.

    Selecting an activity template

  5. In the next screen, you should enter the name of your main activity and the name for your main layout. Menu Resource Name is for the action bar menu layout file.

    Defining the name for the activity and layout

  6. Then, click on Finish. Wait for some time until Gradle builds your project information.

    Your sample app template is now created. Let's now explore Android Studio.

    The section on the left-hand side is the project explorer and the section on the right-hand side is the code editor. You will see three folders: manifests, java, and res inside your app. The manifests folder contains our application's AndroidManifest.xml file. The java folder contains our Java classes, which make our Activities, Fragments, and other functions. The res folder contains all our layout files and styles.

  7. Now, run your application on the Android emulator or on your own physical device. To run the application, you can click on the green Run app icon in the toolbar or you can select Run | Run app.

You will see the text Hello World in TextView. Physical devices are a lot faster than the Android emulator, which runs on your PC.

Exporting the Android application as APK

Your Android app should be exported as APK and signed to be able to publish it in the Google Play store and install it on your device. In order to sign an APK, you need to create a key store. Let's see how to export in Android Studio.

  1. Select Build | Generate Signed APK.

  2. The Generate Signed APK Wizard window will appear. You need to create a new key store by selecting the Create new button. Enter the required details. One of the fields in the Certificate section needs to be nonempty. You can leave the rest of the fields empty. The minimum validity should be 25 years.

    Creating a new key store

  3. Then, select OK. Your new key store will be created. If you have already created a key store, you can use it. It is recommended to sign different apps you create with the same key store. Key store is used to authenticate you. So, keep your key store safe. Note that, if you lose your key store, you can't update your app published in Play store.

    The following screenshot shows the Generate Signed APK Wizard window:

    Generate Signed APK Wizard

  4. Then, select Next. In the next window, you should select the destination folder of your APK. Then, select the build type, whether it is Release or Debug. While running our app on the virtual device, it will run in the Debug mode. You cannot distribute a Debug build in Play store. The Release build is the final build that can be uploaded to the Play store in which the app must be signed with your own certificate. Finally, select Finish. Your APK will be generated.