Skip to main content

Exploring The IDE

In this section you explore the Android Studio Integrated Development Environment, Which is also known as the IDE. Basically, the IDE is the interface between you and Android Studio. The more you know about the tools, windows , and options that are available to you in Android Studio , the faster you will be able to produce code and the more confident you will be at creating applications.

1. If you haven't already, open Android Studio. If you worked through last Blog , you created a very quick Hello World project. You are going to create another quick project for this blog ; this time , however , you explore the different options available as you start up and work with your project.

2. Now that you have opened Android Studio , you see should a screen that looks like show


NOTE :- if you not see the screen in figure and instead see the last Hello world Project from last blog , simply locate the File option on the menu bar , Click File -> Close Project to return to the screen show.

3. The Android Studio welcome screen contains an option for you to open existing projects that you might have already created Android Studio. It also presents options for opening a project from VCS , and importing projects from other IDEs, such as Eclipse.

 4. Click the Start a new Android Studio Project option from the Android Studio welcome screen. You should now see the Create New Project, which enables you to configure some of the basic options for your project.


 The first option you have is to name your project. Let's call this one IDEExplorer. The second option - the Company Domain - is very important because it is used to name the java package to which your code will belong. You can type any name that you want into this field. There is no validation to check that you actually own the domain that you specify , but you should try to use a valid domain. I have used theappguruz.com As you can see the Package Name line , Android Studio automatically reverses you company domain to create the package name.

NOTE :- the package name is used in almost every code file in your project. It helps Android Studio identify which file belong to your project(and Which , for example , belong to the core Java libraries).Throughout this blog, when you look at the provided code samples, I remind you to replace all instances of my package name (com.theappguruz) with whatever package name you select here. If you do not , Android Studio doesn't know that the example code should belong to your project rather than mine.

The final option on create New project screen is the path to which Android Studio will save your new project. I typically accept the default here because it makes it easier for me to find projects in the future. However , feel free to specify any valid location that you want to use - it will not affect this tutorial. Click Next to Continue.


The next screen allows you to select the from factor on which your application will run. For the purposes for this blog, you exclusively use Phone and Tablet. The version of Android is Android N (or Nougat , depending on the version of the SDK you downloaded. As of the writing of this blog , the name was officially announced as Nougat , but the SDK was still labeled N).



The other options on this screen allow to create application that run on Android Wear , Android Auto , and the elusive Google Glass. If you are feeling adventurous after reading this blog , feel free to try some of these other application form factor options. For now , make sure to select Phone and Tablet and Android N and Click to continue.

The next screen is the Add an Activity to Moblie screen , as shown in Figure. This screen is a helper that adds commonly used features to this project at the time the project is created. 

The options on this screen range from Add No Activity to Tabbed Activity. For example , if you were to select the Google Maps Activity option , Android Studio would create for you a project with a basic activity that contains a Google Map in it already. This can drastically cut down on the amount of time needed to create some type of applications.


The default option is Empty Activity . This is the most useful for examples because it creates a basic activity for you , with no code in it - thus allowing you to easily follow the examples in this blog.

NOTE :- Unless otherwise specified in this blog , all of the examples in the blog assume you select the Empty Activity Option.  

 Click Next to go to the Customize the Activity screen , as show in Figure.


 The Customize the Activity screen contains two options, one for naming your activity , and one for naming the main layout (presumably to used by the main activity). Let's explore these two options.
  •  It is accepted practice in Android development to name your main activity - that is , the activity that is loaded on startup by your application - as MainActivity. The reason for this is to make it easier to locate the startup code for application. If anyone else needs to look at or work with your application , they should know that MainActivity is the starting point . All other activities can be named by their function , for example InputFormActivity or DeleteRecordActivity.
  • The layout file follows the "name" naming convention. The startup Layout , that is the layout for screen elements that will be displayed when your application is started the user, is the activity_main layout. All other layout should be named according to the activity that they support (activity_input, activity_delete).
NOTE :- Unless otherwise specified , all of the examples in this blog assume that you accept the defaults on the Activity screen of MainActivity and activity_main.

Click the Finish Button to finish creating the project and jump into exploring the IDE. The Android Studio IDE should now be visible to you as show in figure.



The Upper portion of the IDE represents the menu bars or ribbons. Here, as with most applications that you have used in the past, you have all of your options for interacting directly with the IDE. The most important ones to note are the green arrow , which represents the run app option , and green arrow with a bug behind it , which is the Debug App option . The Debug App option is arguably the one that you use the most in this blog.

By default , the left side of the IDE shows the Project window , as show in Figure. The project window enables you to quickly navigate the file within you project. By default, the project window is set to Android view. To change the view , click the word Android and use the drop-down list of options to make the change. I like to keep mine on Project view when I am Working.


On the Right side of the IDE ( and taking up the largest area ) are the Editor tabs. The Editor tabs are where you write and work with your code files.



To work on a new file , simply locate the file in the Project window and double-click it to open a new Editor tab that contains that file's code. If you need to create a new file scratch , right-click the directory into which you want to place your file , and select New -> <File Type> from the context menu.

Finally , at the bottom of the IDE , you should see a button labeled Android Monitor. Click this button to open the Android Monitor.


The Android Monitor automatically displays when you debug an application. It contains a very useful tool called logcat.Logcat Displays most of the helpful messages the are output by your application while you trying to debug it . you will make use of logcat - including writing custom messages to it.

Comments

Popular posts from this blog

Applying Styles and Themes to an Activity

By default , an activity is themed to the default Android theme. However , there been a push in recent year to adopt a new theme known as Material . The Material theme has a much more modern and clean look to it. There are two versions of the Material theme available to Android developers : Material Light and Material Dark , Either of these themes can be applied from the AndroidManifest.xml To apply one of the Material themes to an activity , simply modify the <Application> element in the AndroidManifest.xml file by changing the default android:theme attribute. (Please be sure to change all instances of "com.android" to whatever package name your project is using.) <?xml version="1.0" encoding="utf-8"?> <manifest xmls:android="http://schemas.android.com/apk/res/android"        xmlns:tools="http://schemas.android.com/tools"        package="com.android.activity101">        <application ...

Using Code Completion

Code completion is an invaluable tool that shows you contextual options for completing the piece of code that you are trying to write. For example, in the editor tab for the MainActivity.js file, locate the line that reads.          setContentView(R.layout.activity_main); Place your cursor after this line and press the Enter Key . On the new line , type the letter R , and then type a period, as shown here:          R. Android Studio Code Completion should display a list of values that you could use to try to complete the code statement. Figure shows what this list might look like . this is important if you are not entirely sure of the spelling of a method call or how to identify the different method signatures. NOTE if the code completion window does not open , press Ctrl + Space to force it to open. This is the same key combination used in some other IDEs for their versions of the code complet...

Now in Android

Android Studio 4.2 discharged to steady channel   Android Studio 4.2 is now available in the stable release channel. Read the blog for detailed information on what’s new, including a new tool to help migrate your project to the latest Android Gradle Plugin version. We’ve also enhanced lots of stuff such as Database Inspector , System Trace , SafeArgs support, Apply Changes, and the new project wizard. As always, download here and file issues here .           Hilt is stable and ready for production Manuel Vivo wrote about the stable release of Hilt , Android Jetpack’s recommended dependency injection (DI) solution for Android apps. Hilt is a simpler, more opinionated way to leverage the power of the Dagger DI library, eliminating boilerplate and reducing errors. It provides direct injection support for popular Jetpack libraries such as ViewModel, WorkManager, Navigation, and Compose. ( DI Basics , Documentation )   Google Play updates ...