Android Adventures - Getting Started With Android Studio
Written by Mike James   
Tuesday, 21 January 2014
Article Index
Android Adventures - Getting Started With Android Studio
Project Structure
From Code to Emulator
Running the App

 

Running The App

Once the AVD is running and fully booted into Android you can run your app. Running the app is just a matter of clicking the green triangle icon or using the menu command Run,Run. Android Studio first compiles your code and gets it ready to execute - You might see error messages at this stage if there is anything wrong with the code. 

Next you will be asked to select which AVD or real device you want to run the program on. You can have multiple emulated devices and real devices connected and pick which one to test on each time you run. In our case there should only be one AVD running. 

 

SelectAVD

 

If you look at the Run window at the bottom of the Android Studio main Window you will see a succession of status messages indicating the progress of loading the app - from Waiting for device though uploading file to Success. 

You app will appear on the emulator and run. In our case this isn't particularly impressive - just the words Hello Android World - but when you think of the journey traveled it really should impress. 

 

apprun

 

From this point you can now modify the code or the layout and run the app again to see the effects of the changes. You still have a lot to discover about how to extend the app and make it useful but - the adventure has begun.

Summary

  • Android Studio makes creating Android apps a lot easier than other approaches. 

  • An app has at least one Activity and this defines a screen layout and a behavior. 
  • To create a simple application use the Blank Activity template with no extras selected.
  • The screen layout is controlled by an XML markup file, Main_Activity.xml in our case stored in the res directory.

  • Android Studio provides a drag-and-drop designer that allows you to create a UI without having to work directly with the XML.

  • The behavior of the app is controlled by a Java file, MainActivity.java in our case stored in the java directory. You can edit the code in the Java file directly in Android Studio.

  • To run an app you need either an emulator based AVD or a real Android device connected to the machine. 

  • You need to create at least one AVD and start it running before trying to test your app.

  • When you run the app you can select which AVD or which hardware device is used to test it. 

  • You can modify and re-run your app without having to restart the AVD or any real hardware connected to the machine. 


Androidgears

Android Adventures With Android Studio

 

 

Contents

  1. Getting Started With Android Studio
  2. The Activity And The UI
  3. Building The UI and a Calculator App
  4. Lifecycle and State
  5. Basic Controls And Events
  6. Spinners
  7. Pickers
  8. UI Graphics A Deep Dive
  9. Introducing Fragments
  10. Fragments and XML
  11. Fragment And Activity Working Together
  12. Managing Fragments
  13. Dialog Fragments

If you are interested in creating custom template see:

Custom Projects In Android Studio

Coming Next

In the next installment we'll discover how to build a UI using components.

Meanwhile if you have any questions on what we've covered so far please let me know using the comments.

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.

 

blog comments powered by Disqus

 

 



Last Updated ( Wednesday, 09 April 2014 )
 
 

   
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.