Tutorial for developing the Snake Game in Android: What is Android?
|
|
|
- Hannah McKinney
- 10 years ago
- Views:
Transcription
1 Tutorial for developing the Snake Game in Android: What is Android? Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. Application Fundamentals: Android applications are written in the Java programming language. The Android SDK tools compile the code along with any data and resource files into an Android package, an archive file with an.apk suffix. All the code in a single.apk file is considered to be one application and is the file that Android-powered devices use to install the application. The objective of this android tutorial would be a) Install the Android SDK on Mac and configure with eclipse b) Create a sample application (Hello World) that runs on the Android Emulator and then create the snake game. We find the game is taking time to configure and run. c) Hence, the same game is uploaded in the Android Tablet and tested for its speed.it is running fast and it is ready to play. Three versions of the game are created. The first one wherein the snake eats the apple grows in size and increases its speed. This works with the Android tablet only when it is connected to the external keyboard. To avoid this, the second version of the game was created where in the snake is controlled by touching it by hand on the Android tablet. The third version was created for the fun element of the accelerometer which controls the movement of the snake. The purposes of all three versions are the same though. 1. Getting Started with Android Development This tutorial shows you how to download and install Android SDK to get you started developing Android applications. 1. Install Java : Check whether the system has Java already installed in it by going to Applications > Utilities > Terminal. Just type java version. If it says a version, then Java download is not necessary. Current version is: 1.6.0_31 Otherwise, click html and select the jdk-7u4-macosx-x64.dmg for Mac OS from Java SE development
2 kit 7u4. Just download and install it.(for windows, select jdk-7u4-windowsx-i586.exe and download and install it). Otherwise upload the package named jdk-7u4-macosx-x64.dmg into the desktop from the zipped drive. 2. Install Eclipse: Go to to download a copy of eclipse. The page will look like this: The first item listed is "Eclipse IDE for Java Developers (98 MB)." On the right is a green, downward-pointing arrow. Next to that are links labeled "Mac OS X 32 Bit" and "Mac OS X 64 Bit." Click on the "Mac OS X 32 Bit" link. (For windows just choose the windows option and follow the same instructions of installation.) You will see a window like this:
3 Click on the green, downward pointing arrow. A download of eclipse-java-helios-sr2- macosx-cocoa.tar.gz will start. If you first get a window like this just click "OK" so that the downloaded file opens with Archive Utility. The download will go to your Downloads folder. You will normally have an icon for the Downloads folder on the right-hand side of the dock. Find eclipse-java-helios-sr2- macosx-cocoa.tar.gz in your Downloads folder, and drag it to the Desktop. Then doubleclick it. You will see a folder named "eclipse." // Otherwise, just drag the eclipse-jeeindigo-sr2-macosx-cocoa.tar.gz from the zipped drive into the desktop and follow the instructions. 1. Drag the "eclipse" folder into your Applications folder. The easiest way to do so is to open a new window in the Finder and click on Applications in the list you get on the lefthand side. Then drag the "eclipse" folder in with the other applications. Make sure that you do not drag it into a folder that's already within Applications. In other words, when you're done, the Applications folder should have directly within it a folder named "eclipse." 2. (This step is not required, but it's strongly recommended.) Double click the "eclipse" folder. You'll see an application named "Eclipse"; it has a purple icon with white
4 horizontal stripes. Drag it into your dock. Now you will be able to launch Eclipse by clicking on the icon in the dock. 3. You may now drag eclipse-java-helios-sr2-macosx-cocoa.tar.gz to the Trash. Empty the Trash whenever you wish. 4. When you launch Eclipse for the first time, you'll be asked "'Eclipse' is an application downloaded from the Internet. Are you sure you want to open it?" Click "Open." 5. You'll see something like the following window: Of course, the workspace name will have your user name in place of "thc." You can choose whatever place you want for your workspace, but it's easiest to just use the default you're given. I recommend that you just click the checkbox next to "Use this as the default and do not ask again" and then click "OK." 6. You'll then see the following screen: Click on the folded-over arrow on the right. You won't see this screen again, even if you quit Eclipse and relaunch it.
5 7. Now you'll see the following screen: 8. You have now installed Eclipse! 2.1. Install the ADT Plug-in Start Eclipse, then select Help > Software Updates or Help>Install New Software. In the dialog that appears, click the Available Software/Install New Software tab. Click Add Site. In the Add Site dialog that appears,
6 Copy and paste this link into input box Location/Work with : Back in the Available Software view, you should see the plugin.(for Windows,just add the name as ADT plugin and check the developer tools box and continue with the instructions of mac). Android Developer Tools, and Android Editors should both be checked. The Android Editors feature is optional, but recommended. Then click on the button Install Click on the button next Check the I accept the terms of the license agreements and click Finish. Eclipse will ask to restart, click on the button Yes. After restart, update your Eclipse preferences to point to the SDK directory: 2.2. Android SDK : Download the Android SDK from this link // Otherwise just drag the file from the zipped drive into the desktop and continue with the instructions below.
7 Install the Android SDK (android-sdk_r17-macosx.zip). To install the Android SDK in Mac OS X, all you need to do is unzip the package that you downloaded, and place it in the Applications folder. Begin by right-clicking on the package you downloaded, and using the Archive Utility to extract the files. After you have extracted the files, you ll see a newly created folder called android-sdk-macosx. Drag that in the Applications folder. 4. Install the ADT Plugin for Eclipse. This part of the procedure installs the Android Development Tools (ADT) plugin for Eclipse. It s what ties together Eclipse and the Android SDK. You install it via Eclipse, using the Help Install New Software menu of Eclipse. First thing is to fire up Eclipse. Double-click on the Eclipse executable in the Applications/Eclipse folder (or wherever you put it), and you ll see the Eclipse splash screen.
8 The first thing you ll have to decide is where to configure your workspace. Unless you have a reason to change from the default, go with what it suggests. Once you have that set, and hit OK, the main Eclipse screen should come up. Now you want to go to Help Install New Software, and configure the screen to hit the correct software repository. Here is the initial screen you ll get. See the Add button on the right-hand side near the top? Click it, and here s what you ll get.
9 OK, that s not totally what you ll get. You ll need to type in both the Name (ADT Plugin for Eclipse) and the Location ( Now you can hit OK. After a few seconds it ll connect to the Google site, and then you ll see this screen. Go ahead and hit Select All as I ve done in this example. Hit Next to review the Install Details. Hit Next again, and select I accept the terms of the license agreements. That should enable the Finish button, which you should now hit. The following screen will pop up, which indicates you are now installing the software!
10 In the course of the install, you may see the following security warning. Just go ahead and hit OK and things will proceed. At this point, you may get a series of errors, and one of them may look like this. Click on Open Preferences, and see this screen. Click on Browse and navigate to where you put the Android SDK folder. It ll look like this Click Apply, then OK, and you re all done! Now it s time to configure the Android SDK for Development Tools and the Google APIs. You re almost done! 1. Configure the Android SDK for Development Tools and Google API. This is where you configure the Android SDK Manager to download the tools you will need to create the application. This is essentially downloading the Google API's Platform 2.2 and API level 8. Start by bringing up the Android SDK Manager in Eclipse. Do this by starting Eclipse, then going to Window Android SDK Manager. The following screen will appear, and your goal is to make it look like the image you see here. Select the Android 3.0 version and its corresponding tools and packages which is compatible with our application.(the game of Snake)
11 Now click Install 6 packages (or whatever number you end up having), and you ll get this screen. Click on the Accept All radio button, which should turn all the checkmarks in the packages list to green. Now hit Install.
12 Watch the log until it says you are done and you can close. Then hit Close. This part of the process may take some time depending on the speed of your Internet connection. Once the install is done, and it says you can hit Close, you ve successfully installed the Android SDK, Eclipse, and the ADT Plugin for Eclipse! Configuring a Virtual Device (Creating an AVD) : Once you have installed the required packages, you can use the Android SDK and AVD Manager to set up a virtual device that can be used in your development environment. This
13 allows you to test your applications without requiring a physical Android device. You can set up a virtual device as follows: 1. Make sure the Android SDK and AVD Manager is running. To start AVD Manager Click on Window > AVD Manager. 2. Choose Virtual devices from the left hand panel (if you see that or go to step 3). 3. Select a file name New Type in a name for the file (Android-Test) for the virtual device. 5. Set the Target to at least Android API Level 8.(In our application, set the target as android 3.0) 6. Fill in the SD Card Size. 7. Optionally enable Snapshot. This speeds up the launch of the emulator. 8. Select Create AVD. Starting the Virtual Device Simulator You can launch the emulator by highlighting the virtual device you created and selecting Start , Create a New Android Project After you've created an AVD you can move to the next step and start a new Android project in Eclipse. 1. In Eclipse, select File > New > Project... If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Android" which should contain "Android Project. Select "Android
14 Project" and click Next. 2. Fill in the project details with the following values: o Project name: HelloAndroid o Build Target: Select a platform version that is equal to or lower than the target you chose for your AVD. o Application name: Hello, Android o Package name: com.example.helloandroid (or your own private namespace) o Create Activity: HelloAndroid Click Finish.
15 Here is a description of each field:
16 Project Name This is the Eclipse project name the name of the directory that contains the project files. Build Target This is the version of the Android SDK that you're using to build your application. For example, if you choose Android 2.1, your application will be compiled against the Android 2.1 platform library. The target you choose here does not have to match the target you chose for your AVD; however, the target must be equal to or lower than the target you chose for your AVD. Android applications are forward-compatible, which means an application will run on the platform against which it is built as well as all platforms that are released in the future. For example, an application that is built against the 2.1 platform library will run normally on an AVD or device that is running the The reverse is not true. Application Name This is the human-readable title for your application the name that appears on the Android device. Package Name This is the package namespace (following the same rules as for packages in the Java programming language) that you want all your source code to reside under. This also sets the package name under which the stub Activity is generated. Your package name must be unique across all packages installed on the Android system; for this reason, it's important to use a standard domain-style package for your applications. The example above uses the "com.example" namespace, which is a namespace reserved for example documentation when you develop your own applications, you should use a namespace that's appropriate to your organization or entity. Create Activity This is the name for the class stub that is generated by the plugin. This is a subclass of Android's Activity class. An Activity is simply a class that can run and do work. It can create a UI if it chooses, but it doesn't need to. As the checkbox suggests, this is optional, but an Activity is almost always used as the basis for an application.
17 Min SDK Version This value specifies the minimum API Level on which your application will run. The Min SDK Version should be the same as the Build Target you chose. For example, if the Build Target is Android 2.1, then the Min SDK Version should be 7 or lower (it can never be higher than 7). For more information, see Android API Levels. Other fields: The checkbox for "Use default location" allows you to change the location on disk where the project's files are generated and stored. Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.java file, located inside HelloAndroid > src > com.example.helloandroid. It should look like this: package com.example.helloandroid; import android.app.activity; import android.os.bundle; public class HelloAndroid extends Activity /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.main); Notice that the class is based on the Activity class. An Activity is a single application entity that is used to perform actions. An application may have many separate activities, but the user interacts with them one at a time. The oncreate() method is called by the Android system when your Activity starts it is where you should perform all initialization and UI setup. An activity is not required to have a user interface, but usually does. Now let's modify some code! Construct the UI Take a look at the revised code below and then make the same changes to your HelloAndroid class. The bold items are lines that have been added. package com.example.helloandroid; import android.app.activity; import android.os.bundle; import android.widget.textview;
18 public class HelloAndroid extends Activity /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); TextView tv = new TextView(this); tv.settext("hello, Android"); setcontentview(tv); Tip: An easy way to add import packages to your project is to press Ctrl-Shift-O (Cmd-Shift- O, on Mac). This is an Eclipse shortcut that identifies missing packages based on your code and adds them for you. You may have to expand the import statements in your code for this to work. An Android user interface is composed of hierarchies of objects called Views. A View is a drawable object used as an element in your UI layout, such as a button, image, or (in this case) a text label. Each of these objects is a subclass of the View class and the subclass that handles text is TextView. In this change, you create a TextView with the class constructor, which accepts an Android Context instance as its parameter. A Context is a handle to the system; it provides services like resolving resources, obtaining access to databases and preferences, and so on. The Activity class inherits from Context, and because your HelloAndroid class is a subclass of Activity, it is also a Context. So, you can pass this as your Context reference to the TextView. Next, you define the text content with settext(). Finally, you pass the TextView to setcontentview() in order to display it as the content for the Activity UI. If your Activity doesn't call this method, then no UI is present and the system will display a blank screen. There it is "Hello, World" in Android! The next step, of course, is to see it running. Run the Application The Eclipse plugin makes it easy to run your applications: 1. Select Run > Run. 2. Select "Android Application". The Eclipse plugin automatically creates a new run configuration for your project and then launches the Android Emulator. Depending on your environment, the Android emulator might take several minutes to boot fully, so please be patient. When the emulator is booted, the Eclipse
19 plugin installs your application and launches the default Activity. You should now see something like this: The "Hello, Android" you see in the grey bar is actually the application title. The Eclipse plugin creates this automatically (the string is defined in the res/values/strings.xml file and referenced by your AndroidManifest.xml file). The text below the title is the actual text that you have created in the TextView object. Upgrade the UI to an XML Layout The "Hello, World" example you just completed uses what is called a "programmatic" UI layout. This means that you constructed and built your application's UI directly in source code. If you've done much UI programming, you're probably familiar with how brittle that approach can sometimes be: small changes in layout can result in big source-code headaches. It's also easy to forget to properly connect Views together, which can result in errors in your layout and wasted time debugging your code.
20 That's why Android provides an alternate UI construction model: XML-based layout files. The easiest way to explain this concept is to show an example. Here's an XML layout file that is identical in behavior to the programmatically-constructed example: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" The general structure of an Android XML layout file is simple: it's a tree of XML elements, wherein each node is the name of a View class (this example, however, is just one View element). You can use the name of any class that extends View as an element in your XML layouts, including custom View classes you define in your own code. This structure makes it easy to quickly build up UIs, using a more simple structure and syntax than you would use in a programmatic layout. This model is inspired by the web development model, wherein you can separate the presentation of your application (its UI) from the application logic used to fetch and fill in data. In the above XML example, there's just one View element: the TextView, which has five XML attributes. Here's a summary of what they mean: Attribute xmlns:android android:id Meaning This is an XML namespace declaration that tells the Android tools that you are going to refer to common attributes defined in the Android namespace. The outermost tag in every Android layout file must have this attribute. This attribute assigns a unique identifier to the TextView element. You can use the assigned ID to reference this View from your source code or from other XML resource declarations. android:layout_width android:layout_height This attribute defines how much of the available width on the screen this View should consume. In this case, it's the only View so you want it to take up the entire screen, which is what a value of "fill_parent" means. This is just like android:layout_width, except that it refers to available screen height. android:text This sets the text that the TextView should display. In this example, you use a string resource instead of a hard-coded string value. The hello string is defined in the res/values/strings.xml file. This is the recommended
21 practice for inserting strings to your application, because it makes the localization of your application to other languages graceful, without need to hard-code changes to the layout file. For more information, see Resources and Internationalization. These XML layout files belong in the res/layout/ directory of your project. The "res" is short for "resources" and the directory contains all the non-code assets that your application requires. In addition to layout files, resources also include assets such as images, sounds, and localized strings. Landscape layout When you want a different design for landscape, put your layout XML file inside /res/layoutland. Android will automatically look here when the layout changes. Without this special landscape layout defined, Android will stretch the default layout. The Eclipse plugin automatically creates one of these layout files for you: main.xml. In the "Hello World" application you just completed, this file was ignored and you created a layout programmatically. This was meant to teach you more about the Android framework, but you should almost always define your layout in an XML file instead of in your code. The following procedures will instruct you how to change your existing application to use an XML layout. 1. In the Eclipse Package Explorer, expand the /res/layout/ folder and open main.xml (once opened, you might need to click the "main.xml" tab at the bottom of the window to see the XML source). Replace the contents with the following XML: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android=" android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> Save the file. 2. Inside the res/values/ folder, open strings.xml. This is where you should save all default text strings for your user interface. If you're using Eclipse, then ADT will have started you with two strings, hello and app_name. Revise hello to something else. Perhaps "Hello, Android! I am a string resource!" The entire file should now look like this: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">hello, Android! I am a string resource!</string> <string name="app_name">hello, Android</string> </resources>
22 3. Now open and modify your HelloAndroid class and use the XML layout. Edit the file to look like this: package com.example.helloandroid; import android.app.activity; import android.os.bundle; public class HelloAndroid extends Activity /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.main); When you make this change, type it by hand to try the code-completion feature. As you begin typing "R.layout.main" the plugin will offer you suggestions. You'll find that it helps in a lot of situations. Instead of passing setcontentview() a View object, you give it a reference to the layout resource. The resource is identified as R.layout.main, which is actually a compiled object representation of the layout defined in /res/layout/main.xml. The Eclipse plugin automatically creates this reference for you inside the project's R.java class. If you're not using Eclipse, then the R.java class will be generated for you when you run Ant to build the application. (More about the R class in a moment.) Now re-run your application because you've created a launch configuration, all you need to do is click the green arrow icon to run, or select Run > Run History > Android Activity. Other than the change to the TextView string, the application looks the same. After all, the point was to show that the two different layout approaches produce identical results. Note: You may have to unlock the screen on the emulator to see your application just as you would unlock the screen on a device. R class: In Eclipse, open the file named R.java (in the gen/ [Generated Java Files] folder). It should look something like this: package com.example.helloandroid; public final class R public static final class attr
23 public static final class drawable public static final int icon=0x7f020000; public static final class id public static final int textview=0x7f050000; public static final class layout public static final int main=0x7f030000; public static final class string public static final int app_name=0x7f040001; public static final int hello=0x7f040000; A project's R.java file is an index into all the resources defined in the file. You use this class in your source code as a sort of short-hand way to refer to resources you've included in your project. This is particularly powerful with the code-completion features of IDEs like Eclipse because it lets you quickly and interactively locate the specific reference you're looking for. It's possible yours looks slightly different than this (perhaps the hexadecimal values are different). For now, notice the inner class named "layout", and its member field "main". The Eclipse plugin noticed the XML layout file named main.xml and generated a class for it here. As you add other resources to your project (such as strings in the res/values/string.xml file or drawables inside the res/drawable/ directory) you'll see R.java change to keep up. When not using Eclipse, this class file will be generated for you at build time (with the Ant tool). You should never edit this file by hand. Debug Your Project: The Android Plugin for Eclipse also has excellent integration with the Eclipse debugger. To demonstrate this, introduce a bug into your code. Change your HelloAndroid source code to look like this: package com.example.helloandroid; import android.app.activity; import android.os.bundle; public class HelloAndroid extends Activity /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate);
24 Object o = null; o.tostring(); setcontentview(r.layout.main); This change simply introduces a NullPointerException into your code. If you run your application again, you'll eventually see this: Press "Force Quit" to terminate the application and close the emulator window. To find out more about the error, set a breakpoint in your source code on the line Object o = null; (double-click on the marker bar next to the source code line). Then select Run > Debug History > Hello, Android from the menu to enter debug mode. Your app will restart in the emulator, but this time it will suspend when it reaches the breakpoint you set. You can then step through the code in Eclipse's Debug Perspective, just as you would for any other application.
25
26 Creating a simple Snake game: Snake is a classic game in which the player controls a snake that moves around and eats fruit. With each fruit that the snake eats, it grows in length by one, and the player earns one point. The player loses the game when the snake either collides with it's tail, or a wall. This series will cover the creation of the snake game from start to finish, and will provide full source code at the end. This will be broken up into several parts, each covering a different section of the game before putting it all together and supplying the source code at the end. Android is structured so that applications may use relevant pieces of other applications, without having to load all of the other application. This ability is important in implementing "lean and mean" applications that use minimal resources, and implies that well-written Android applications must be highly modular, with multiple entry points. The snake game also consists of common files as in android with additions made to it for the purpose of this gaming app lication. Let us see the version 2 in detail since we can run it with the help of both simulator and Android tablet. Version 2: Click on New>Android Project; Type in the project name as snake. click ok. Type in the application name as snake,1 and package name as com.snake3.android.just select the activity and click finish.(as we did for Hello Android). Loading the resources: Download the resources required from the internet and zip it into a folder. Import them into the res > drawable >.png file. 1. Button.png 2. Icon.png 3. Logo.png 4. Tiles.png The Resources folder is given below to easily import into Eclipse. The AndroidManifest.xml File First start creating the android manifest file by getting into Res > Android manifest.xml
27 Android must know that a component of an application exists before it can start it. This is accomplished by having applications declare their components in an XML manifest file that is always called AndroidManifest.xml, and that every application must contain. As we shall find, the manifest file does many other things, such as naming any external libraries the application needs to be linked against and identifying any permissions the application expects to be granted, but its most fundamental task is to inform Android about the application's components. Modify the AndroidManifest.xml file for the snake game to add any specific permissions that you know the project will require. This file declares the content of the Snake application. The code below will add the required lines: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="com.snake3.android" android:versionname="2.7" android:versioncode="9"> <uses-sdk android:minsdkversion="7" /> <application android:icon="@drawable/icon" android:label="@string/app_name" android:allowclearuserdata="false" android:description="@string/description" android:enabled="true" android:testonly="false" android:killafterrestore="true" android:restoreneedsapplication="true" android:allowtaskreparenting="true" android:hascode="true" android:persistent="false" android:debuggable="false"> <activity android:name=".snake3" android:label="@string/app_name" android:screenorientation="portrait" android:configchanges="orientation keyboardhidden"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest> in which the activity,.snake3 is declared. The application starts control from the manifest file which primarily refers the main files. This is to make the device and the game application to communicate with each other.
28 Creating the layout: The recommended way to lay out the view hierarchy is with an XML layout file. Here, we use the relative layout: Relative Layout is a View Group that displays child View elements in relative positions. The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the Relative Layout area (such as aligned to the bottom, left of center). A Relative Layout is a very powerful utility for designing a user interface because it can eliminate nested View Groups. To create this, get into res > layout > main.xml. Here is the simple XML relative layout file which we call in the main. xml file in this snake game: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.snake3.android.playfield android:id="@+id/playfield1" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:layout_width="fill_parent" android:layout_height="fill_parent"> </com.snake3.android.playfield> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button1" android:layout_centervertical="true" android:layout_centerhorizontal="true" android:background="@drawable/button" android:textappearance="@style/bold" android:freezestext="true" android:textcolor="@color/red" android:text="@string/startbutton"></button> <TextView android:id="@+id/textview1" android:textappearance="?android:attr/textappearancelarge" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="textview" android:layout_above="@+id/button1" android:layout_centerhorizontal="true"></textview> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" android:id="@+id/button2" android:layout_alignparenttop="true" android:layout_alignparentright="true"></button>
29 <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true"></imageview> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerinparent="true" android:focusableintouchmode="true" </RelativeLayout> This layout would create a TextView, an image view and 3 buttons, arrayed in a relative layout in the Android window. As long as you follow the rules, you do not have to worry about managing the relationship between XML layout of the UI and the Java code that will reference it. Basically you must just place correctly written code in a standardized set of directories and Android will do the rest. When you load a layout resource, Android automatically initializes these run-time objects, corresponding to the elements in your layout. Click res > values > string.xml file and type in the following code : <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">snakegame</string>. <string name="startbutton">start</string> <string name="pausebutton">pause</string> <string name="restartbutton">restart</string> <style name="bold"><item name="android:textsize">20sp</item></style> <string name="score">your Score was: </string> <string name="description">snake, swipe in the direction you want to move</string> <color name="red">#f00</color> <string name="credits">credits</string> </resources> The resources file will automatically change as the screen shown below:
30 The Graphical layout of the main.xml will look like this: The Buildconfig.Java and R.Java files in the folder gen are automatically created when changes to the xml files we created are made.
31 The package com.snake3.android is the heart of the game which consists of four java files: 1. Snake.java 2. Game Engine.java 3. gamethread.java 4. playfield.java Snake.java is the file that contains labels and buttons and how they are made to work: package com.snake3.android; /**import these buttons and alertdialog which are existing already*/ import java.util.timer; import java.util.timertask; import android.app.activity; import android.app.alertdialog; import android.app.alertdialog.builder; import android.graphics.color; import android.os.bundle; import android.os.handler; import android.view.view; import android.widget.button; import android.widget.imageview; import android.widget.textview; /** When a new activity is started, it is placed on the top of the stack and becomes the running activity -- the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits. oncreate() is a method that is created when the activity is initialized.*/ public class Snake3 extends Activity /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate); setcontentview(r.layout.main); /** Buttons,Textview and the Imageview locates the R.java(Resources.java file) with the help of the id`s.*/ final playfield game = (playfield)findviewbyid(r.id.playfield1); final Button start = (Button)findViewById(R.id.button1); final Button pause = (Button)findViewById(R.id.button2); final TextView score = (TextView)findViewById(R.id.textView1); final ImageView logo = (ImageView)findViewById(R.id.imageView1);
32 final Button credit = (Button)findViewById(R.id.button3); final Builder credits = new AlertDialog.Builder(this); credits.settitle("credits"); credits.setmessage("credits"); credits.setpositivebutton("ok", null); /** setting the teat color and visibility */ score.settextcolor(color.red); score.setvisibility(view.gone); score.settextappearance(getapplicationcontext(), R.style.bold); pause.setvisibility(view.gone); pause.setbackgroundresource(r.drawable.button); pause.settextcolor(color.red); pause.settextappearance(getapplicationcontext(), R.style.bold); pause.settext(r.string.pausebutton); credit.setonclicklistener(new View.OnClickListener() public void onclick(view v) credits.show(); ); /** setting the onclicklisteners to start,pause the game,score and logo visibility when the game is started */ start.setonclicklistener(new View.OnClickListener() public void onclick(view v) game.startgame(); pause.setvisibility(view.visible); start.setvisibility(view.gone); score.setvisibility(view.gone); logo.setvisibility(view.gone); credit.setvisibility(view.gone); ); pause.setonclicklistener(new View.OnClickListener() public void onclick(view v) game.pause(); ); Timer timer; TimerTask task; final Handler timerhandle; timerhandle = new Handler(); timer=new Timer(); task = new TimerTask()
33 @Override public void run() timerhandle.post(new Runnable() public void run() if(game!=null&&game.gameon()&&game.lost()) String endtext = getstring(r.string.score)+game.getscore(); start.setvisibility(view.visible); score.setvisibility(view.visible); credit.setvisibility(view.visible); start.settext(r.string.restartbutton); score.settext(endtext); ); ; timer.schedule(task, 1000, 500); Game Engine.java: At the heart of every game is the engine. The engine is responsible for updating the game at fixed intervals, in response to events, or a combination of the two. In the case of the Snake Game, we need to update the game at regular intervals, and accept user input from the Keyboard. package com.snake3.android; import java.util.arraylist; import java.util.timer; import java.util.timertask; import android.graphics.bitmap; import android.os.handler; /** To start, we're going to create a new class and name it gameengine. This class will be responsible for handling most of the game's logic, the game loop, and window creation.*/ public class gameengine /** The private variables are declared. Walls, snake and direction are declared in array.*/ private ArrayList<Float> walls; private ArrayList<Float> snake; private ArrayList<Integer> direction; private int width; private int height; private int tilewidth;
34 private int tileheight; private int length; private int currentd; private float[] apple; private Timer snakemover; private TimerTask task; private Handler timerhandle; private int score; boolean playing; boolean lost; boolean paused; /** The arguments width, height and Bitmap tile are passed into the gameengine. The snake grows in size when the game is in the running state.*/ public gameengine(int _width, int _height, Bitmap tile) paused=false; walls = new ArrayList<Float>(); snake = new ArrayList<Float>(); direction = new ArrayList<Integer>(); width=_width; height=_height; tilewidth = tile.getwidth(); tileheight= tile.getheight(); setwalls(); direction.add(integer.valueof(3)); length=5; timerhandle = new Handler(); score=0; apple = new float[2]; generateapple(); playing = false; lost=false; /** If the snake eats the apple,then the score increases.*/ public void checkcollide() if(snake.get(0)==apple[0]&&snake.get(1)==apple[1]) score++; generateapple(); growsnake(); updatetimer(((10000/(height/tileheight)))/((score/3.0)+1)); /** When the snake hits the walls,the game will cancel and the player loses the game*/ for(int i=0;i<walls.size()-1;i+=2)
35 if(snake.get(0).equals(walls.get(i))&&snake.get(1).equals(walls. get(i+1))) lost=true; playing=false; snakemover.cancel(); for(int i=2;i<snake.size()-1;i+=2) if(snake.get(0).equals(snake.get(i))&&snake.get(1).equals(snake. get(i+1))) lost=true; playing=false; snakemover.cancel(); public boolean getplaying() return playing; public void setplaying(boolean play) playing = play; public void updatetimer(double d) if(snakemover!=null) snakemover.cancel(); snakemover=new Timer(); task = new public void run() timerhandle.post(new Runnable() public void run() if(playing) movesnake(); );
36 ; snakemover.schedule(task, 0, (long) d); public void generateapple() int max = width/tilewidth; max-=3; int t=(int) ((Math.random()*10000)%max); t+=2; apple[0]=t*tilewidth; max = height/tileheight; max-=7; t=(int) ((Math.random()*10000)%max); t+=6; apple[1]=t*tileheight; public float[] getapple() return apple; public void initsnake() length=5; direction = new ArrayList<Integer>(); direction.add(integer.valueof(3)); lost=false; snake = new ArrayList<Float>(); score=0; for(int i=0;i<length;i++) snake.add(float.valueof(tilewidth*(20))+(tilewidth*i)); snake.add(float.valueof(tileheight*(20))); updatetimer(10000/(height/tileheight)); public void setwalls() for(int x=0;x<width;x+=tilewidth) for(int y=tileheight*5;y<height;y+=tileheight) if(x==0 x==width-tilewidth y==tileheight*5 y>=heighttileheight) walls.add(float.valueof(x)); walls.add(float.valueof(y));
37 public ArrayList<Float> getwalls() return walls; public ArrayList<Float> getsnake() return snake; public void growsnake() snake.add(snake.get(snake.size()-2)); snake.add(snake.get(snake.size()-2)); public void setdirection(int d) direction.add(integer.valueof(d)); sanitizedirection(); public void sanitizedirection() if(direction.size()>0) if(direction.get(0)==currentd direction.get(0)==(currentd+2)%4) direction.remove(0); for(int i=1;i<direction.size();i++) if(i<direction.size()) if(direction.get(i)==direction.get(i- 1) direction.get(i)==(direction.get(i-1)+2)%4) direction.remove(i); public void movesnake() for(int i=snake.size()-1;i>=0;i-=2)
38 if(i>2) snake.set(i, snake.get(i-2)); snake.set(i-1, snake.get(i-3)); else if(direction.size()>0) currentd=direction.remove(0); switch(currentd) case 0: snake.set(1, Float.valueOf(snake.get(1)+tileHeight)); break; case 1: snake.set(0, Float.valueOf(snake.get(0)+tileWidth)); break; case 2: snake.set(1, Float.valueOf(snake.get(1)-tileHeight)); break; case 3: snake.set(0, Float.valueOf(snake.get(0)-tileWidth)); break; checkcollide(); public int getscore() return score; public boolean lost() return lost; public void pause() if(!paused) snakemover.cancel(); paused=true; else
39 paused=false; updatetimer((10000/(height/tileheight))/((score/3)+1)); Game thread.java package com.snake3.android; import android.graphics.canvas; import android.view.surfaceholder; public class gamethread extends Thread private SurfaceHolder _surfaceholder; private playfield _playfield; private boolean _run = false; public gamethread(surfaceholder surfaceholder, playfield playfield) _surfaceholder = surfaceholder; _playfield = playfield; public void setrunning(boolean run) _run = public void run() Canvas c; while(_run) c = null; try c = _surfaceholder.lockcanvas(null); synchronized (_surfaceholder) _playfield.ondraw(c); finally if(c!= null) _surfaceholder.unlockcanvasandpost(c);
40 Playfield.java: The next step in creating the Snake Game is to create the world(playfield). Without the world, there would be no where for the game to take place, which wouldn't be fun at all. In the case of the Snake Game, the world will be an array of tiles, each with a type, which we can make use of when writing the game's logic. Our game world will be stored in a new class named GameBoard package com.snake3.android; import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.graphics.color; import android.graphics.lightingcolorfilter; import android.graphics.paint; import android.util.attributeset; import android.view.motionevent; import android.view.surfaceholder; import android.view.surfaceview; public class playfield extends SurfaceView implements SurfaceHolder.Callback private gamethread _thread; private Bitmap tile; private Paint wall; private Paint snake; private Paint apple; private gameengine engine; private double initx; private double finalx; private double inity; private double finaly; public playfield(context context, AttributeSet attrs) super(context, attrs); getholder().addcallback(this); setfocusable(true); _thread = new gamethread(getholder(),this); tile = BitmapFactory.decodeResource(getResources(), R.drawable.tiles); setuppaints(); public void setuppaints()
41 wall = new Paint(); snake = new Paint(); apple = new Paint(); apple.setcolorfilter(new LightingColorFilter(Color.RED, 1)); wall.setcolorfilter(new LightingColorFilter(Color.BLUE, 1)); snake.setcolorfilter(new LightingColorFilter(Color.GREEN, 1));//*/ public void surfacechanged(surfaceholder arg0, int arg1, int arg2, int arg3) public void surfacecreated(surfaceholder arg0) if (_thread.getstate() == Thread.State.TERMINATED) _thread = new gamethread(getholder(),this); _thread.setrunning(true); _thread.start(); else _thread.setrunning(true); _thread.start(); engine = new gameengine(getwidth(),getheight(),tile); engine.initsnake(); public void surfacedestroyed(surfaceholder arg0) boolean retry = true; _thread.setrunning(false); while (retry) try _thread.join(); retry = false; catch (InterruptedException e) public void ondraw(canvas canvas) canvas.drawcolor(color.black); if(engine!=null) for(int i=0;i<engine.getwalls().size()-1;i+=2)
42 canvas.drawbitmap(tile, engine.getwalls().get(i), engine.getwalls().get(i+1), wall); for(int i=0;i<engine.getsnake().size()-1;i+=2) canvas.drawbitmap(tile, engine.getsnake().get(i), engine.getsnake().get(i+1), snake); canvas.drawbitmap(tile, engine.getapple()[0],engine.getapple()[1], apple); public boolean ontouchevent(motionevent event) if(engine.getplaying()) if(event.getaction()==motionevent.action_down) initx=event.getx(); inity=event.gety(); double toty=math.abs(math.abs(finaly)-math.abs(inity)); double totx=math.abs(math.abs(finalx)-math.abs(initx)); if(event.getaction()==motionevent.action_move) finalx=event.getx(); finaly=event.gety(); toty=math.abs(math.abs(finaly)-math.abs(inity)); totx=math.abs(math.abs(finalx)-math.abs(initx)); float threshold=20; if(toty>threshold totx>threshold) if(totx>toty) if(finalx>initx) engine.setdirection(1); else if (finalx<initx) engine.setdirection(3); else if(toty>totx) if(finaly>inity)
43 engine.setdirection(0); else if (finaly<inity) engine.setdirection(2); initx=finalx; inity=finaly; return true; public void startgame() engine.setplaying(true); engine.initsnake(); public boolean gameon() return (engine!=null); public int getscore() return engine.getscore(); public boolean lost() return engine.lost(); public void pause() engine.pause(); Once we are done with all the four files the game is all set to run it. Click Project > Clean and clean the project for all the changes we`ve made. Now right click or control click Snake3 and refresh. Now, control click and build project. Finally,run the project as Run > Run As > Android Application. Now, it connects to the AVD. Unlock the lock which is displayed and double click on APPs icon. A set of apps displays from which the Snake 2 is selected. The game opens up and we are all set to play the game. The screen looks like this:
44 Play it and become the highest scorer.
Android Application Development: Hands- On. Dr. Jogesh K. Muppala [email protected]
Android Application Development: Hands- On Dr. Jogesh K. Muppala [email protected] Wi-Fi Access Wi-Fi Access Account Name: aadc201312 2 The Android Wave! 3 Hello, Android! Configure the Android SDK SDK
Android Introduction. Hello World. @2010 Mihail L. Sichitiu 1
Android Introduction Hello World @2010 Mihail L. Sichitiu 1 Goal Create a very simple application Run it on a real device Run it on the emulator Examine its structure @2010 Mihail L. Sichitiu 2 Google
directory to "d:\myproject\android". Hereafter, I shall denote the android installed directory as
1 of 6 2011-03-01 12:16 AM yet another insignificant programming notes... HOME Android SDK 2.2 How to Install and Get Started Introduction Android is a mobile operating system developed by Google, which
ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android
Why Android? ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android Dr Dimitris C. Dracopoulos A truly open, free development platform based on Linux and open source A component-based
Tutorial #1. Android Application Development Advanced Hello World App
Tutorial #1 Android Application Development Advanced Hello World App 1. Create a new Android Project 1. Open Eclipse 2. Click the menu File -> New -> Other. 3. Expand the Android folder and select Android
MMI 2: Mobile Human- Computer Interaction Android
MMI 2: Mobile Human- Computer Interaction Android Prof. Dr. [email protected] Mobile Interaction Lab, LMU München Android Software Stack Applications Java SDK Activities Views Resources Animation
Mobile Application Development
Mobile Application Development (Android & ios) Tutorial Emirates Skills 2015 3/26/2015 1 What is Android? An open source Linux-based operating system intended for mobile computing platforms Includes a
How to build your first Android Application in Windows
APPLICATION NOTE How to build your first Android Application in Windows 3/30/2012 Created by: Micah Zastrow Abstract This application note is designed to teach the reader how to setup the Android Development
Getting Started: Creating a Simple App
Getting Started: Creating a Simple App What You will Learn: Setting up your development environment Creating a simple app Personalizing your app Running your app on an emulator The goal of this hour is
Now that we have the Android SDK, Eclipse and Phones all ready to go we can jump into actual Android development.
Android Development 101 Now that we have the Android SDK, Eclipse and Phones all ready to go we can jump into actual Android development. Activity In Android, each application (and perhaps each screen
Developing Android Apps: Part 1
: Part 1 [email protected] www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems
Android Environment SDK
Part 2-a Android Environment SDK Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 1 2A. Android Environment: Eclipse & ADT The Android
How to develop your own app
How to develop your own app It s important that everything on the hardware side and also on the software side of our Android-to-serial converter should be as simple as possible. We have the advantage that
Chapter 2 Getting Started
Welcome to Android Chapter 2 Getting Started Android SDK contains: API Libraries Developer Tools Documentation Sample Code Best development environment is Eclipse with the Android Developer Tool (ADT)
Android Environment SDK
Part 2-a Android Environment SDK Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 1 Android Environment: Eclipse & ADT The Android
Setting Up Your Android Development Environment. For Mac OS X (10.6.8) v1.0. By GoNorthWest. 3 April 2012
Setting Up Your Android Development Environment For Mac OS X (10.6.8) v1.0 By GoNorthWest 3 April 2012 Setting up the Android development environment can be a bit well challenging if you don t have all
How to Create an Android Application using Eclipse on Windows 7
How to Create an Android Application using Eclipse on Windows 7 Kevin Gleason 11/11/11 This application note is design to teach the reader how to setup an Android Development Environment on a Windows 7
Android Development. http://developer.android.com/develop/ 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系
Android Development http://developer.android.com/develop/ 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系 Android 3D 1. Design 2. Develop Training API Guides Reference 3. Distribute 2 Development Training Get Started Building
Arduino & Android. A How to on interfacing these two devices. Bryant Tram
Arduino & Android A How to on interfacing these two devices Bryant Tram Contents 1 Overview... 2 2 Other Readings... 2 1. Android Debug Bridge -... 2 2. MicroBridge... 2 3. YouTube tutorial video series
Developing NFC Applications on the Android Platform. The Definitive Resource
Developing NFC Applications on the Android Platform The Definitive Resource Part 1 By Kyle Lampert Introduction This guide will use examples from Mac OS X, but the steps are easily adaptable for modern
Android For Java Developers. Marko Gargenta Marakana
Android For Java Developers Marko Gargenta Marakana Agenda Android History Android and Java Android SDK Hello World! Main Building Blocks Debugging Summary History 2005 Google buys Android, Inc. Work on
Hello World. by Elliot Khazon
Hello World by Elliot Khazon Prerequisites JAVA SDK 1.5 or 1.6 Windows XP (32-bit) or Vista (32- or 64-bit) 1 + more Gig of memory 1.7 Ghz+ CPU Tools Eclipse IDE 3.4 or 3.5 SDK starter package Installation
Advantages. manage port forwarding, set breakpoints, and view thread and process information directly
Part 2 a Android Environment SDK Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 1 Android Environment: Eclipse & ADT The Android
Android Development Setup [Revision Date: 02/16/11]
Android Development Setup [Revision Date: 02/16/11] 0. Java : Go to the URL below to access the Java SE Download page: http://www.oracle.com/technetwork/java/javase/downloads/index.html Select Java Platform,
App Development for Android. Prabhaker Matet
App Development for Android Prabhaker Matet Development Tools (Android) Java Java is the same. But, not all libs are included. Unused: Swing, AWT, SWT, lcdui Eclipse www.eclipse.org/ ADT Plugin for Eclipse
IOIO for Android Beginners Guide Introduction
IOIO for Android Beginners Guide Introduction This is the beginners guide for the IOIO for Android board and is intended for users that have never written an Android app. The goal of this tutorial is to
Android Programming Basics
2012 Marty Hall Android Programming Basics Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training: http://courses.coreservlets.com/
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Who am I? Lo Chi Wing, Peter Lecture 1: Introduction to Android Development Email: [email protected] Facebook: http://www.facebook.com/peterlo111
Building Your First App
uilding Your First App Android Developers http://developer.android.com/training/basics/firstapp/inde... Building Your First App Welcome to Android application development! This class teaches you how to
2. Click the download button for your operating system (Windows, Mac, or Linux).
Table of Contents: Using Android Studio 1 Installing Android Studio 1 Installing IntelliJ IDEA Community Edition 3 Downloading My Book's Examples 4 Launching Android Studio and Importing an Android Project
Mocean Android SDK Developer Guide
Mocean Android SDK Developer Guide For Android SDK Version 3.2 136 Baxter St, New York, NY 10013 Page 1 Table of Contents Table of Contents... 2 Overview... 3 Section 1 Setup... 3 What changed in 3.2:...
Android Development. Marc Mc Loughlin
Android Development Marc Mc Loughlin Android Development Android Developer Website:h:p://developer.android.com/ Dev Guide Reference Resources Video / Blog SeCng up the SDK h:p://developer.android.com/sdk/
Creating a 2D Game Engine for Android OS. Introduction
Creating a 2D Game Engine for Android OS Introduction This tutorial will lead you through the foundations of creating a 2D animated game for the Android Operating System. The goal here is not to create
Login with Amazon Getting Started Guide for Android. Version 2.0
Getting Started Guide for Android Version 2.0 Login with Amazon: Getting Started Guide for Android Copyright 2016 Amazon.com, Inc., or its affiliates. All rights reserved. Amazon and the Amazon logo are
Getting Started With Android
Getting Started With Android Author: Matthew Davis Date: 07/25/2010 Environment: Ubuntu 10.04 Lucid Lynx Eclipse 3.5.2 Android Development Tools(ADT) 0.9.7 HTC Incredible (Android 2.1) Preface This guide
INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011
INTRODUCTION TO ANDROID CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 11 02/15/2011 1 Goals of the Lecture Present an introduction to the Android Framework Coverage of the framework will be
Android Java Live and In Action
Android Java Live and In Action Norman McEntire Founder, Servin Corp UCSD Extension Instructor [email protected] Copyright (c) 2013 Servin Corp 1 Opening Remarks Welcome! Thank you! My promise
Admin. Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources. Recap: TinyOS. Recap: J2ME Framework
Admin. Mobile Software Development Framework: Android Activity, View/ViewGroup, External Resources Homework 2 questions 10/9/2012 Y. Richard Yang 1 2 Recap: TinyOS Hardware components motivated design
Installing the Android SDK
Installing the Android SDK To get started with development, we first need to set up and configure our PCs for working with Java, and the Android SDK. We ll be installing and configuring four packages today
Developing In Eclipse, with ADT
Developing In Eclipse, with ADT Android Developers file://v:\android-sdk-windows\docs\guide\developing\eclipse-adt.html Page 1 of 12 Developing In Eclipse, with ADT The Android Development Tools (ADT)
Tutorial: Android Object API Application Development. Sybase Unwired Platform 2.2 SP02
Tutorial: Android Object API Application Development Sybase Unwired Platform 2.2 SP02 DOCUMENT ID: DC01734-01-0222-01 LAST REVISED: January 2013 Copyright 2013 by Sybase, Inc. All rights reserved. This
Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3
Tutorial: Android Object API Application Development SAP Mobile Platform 2.3 DOCUMENT ID: DC01939-01-0230-01 LAST REVISED: March 2013 Copyright 2013 by Sybase, Inc. All rights reserved. This publication
Getting Started with Android Development
Getting Started with Android Development By Steven Castellucci (v1.1, January 2015) You don't always need to be in the PRISM lab to work on your 4443 assignments. Working on your own computer is convenient
Android Development Tutorial. Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011
Android Development Tutorial Nikhil Yadav CSE40816/60816 - Pervasive Health Fall 2011 Database connections Local SQLite and remote access Outline Setting up the Android Development Environment (Windows)
App Development for Smart Devices. Lec #2: Android Tools, Building Applications, and Activities
App Development for Smart Devices CS 495/595 - Fall 2011 Lec #2: Android Tools, Building Applications, and Activities Tamer Nadeem Dept. of Computer Science Objective Understand Android Tools Setup Android
SDK Quick Start Guide
SDK Quick Start Guide Table of Contents Requirements...3 Project Setup...3 Using the Low Level API...9 SCCoreFacade...9 SCEventListenerFacade...10 Examples...10 Call functionality...10 Messaging functionality...10
Lab 0 (Setting up your Development Environment) Week 1
ECE155: Engineering Design with Embedded Systems Winter 2013 Lab 0 (Setting up your Development Environment) Week 1 Prepared by Kirill Morozov version 1.2 1 Objectives In this lab, you ll familiarize yourself
Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen, 2013.06.18
Høgskolen i Telemark Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics Cuong Nguyen, 2013.06.18 Faculty of Technology, Postboks 203, Kjølnes ring
Basics. Bruce Crawford Global Solutions Manager
Android Development Basics Bruce Crawford Global Solutions Manager Android Development Environment Setup Agenda Install Java JDK Install Android SDK Add Android SDK packages with Android SDK manager Install
Android Development Tutorial
3.2k Android Development Tutorial Free tutorial, donate to support Based on Android 4.2 Lars Vogel Version 11.2 Copyright 2009, 2010, 2011, 2012, 2013 Lars Vogel 20.01.2013 Revision History by Lars Vogel
Introduction to Android SDK Jordi Linares
Introduction to Android SDK Introduction to Android SDK http://www.android.com Introduction to Android SDK Google -> OHA (Open Handset Alliance) The first truly open and comprehensive platform for mobile
ADT Plugin for Eclipse
ADT Plugin for Eclipse Android Development Tools (ADT) is a plugin for the Eclipse IDE that is designed to give you a powerful, integrated environment in which to build Android applications. ADT extends
MAP524/DPS924 MOBILE APP DEVELOPMENT (ANDROID) MIDTERM TEST OCTOBER 2013 STUDENT NAME STUDENT NUMBER
MAP524/DPS924 MOBILE APP DEVELOPMENT (ANDROID) MIDTERM TEST OCTOBER 2013 STUDENT NAME STUDENT NUMBER Please answer all questions on the question sheet This is an open book/notes test. You are allowed to
Android Tutorial. Larry Walters OOSE Fall 2011
Android Tutorial Larry Walters OOSE Fall 2011 References This tutorial is a brief overview of some major concepts Android is much richer and more complex Developer s Guide http://developer.android.com/guide/index.html
Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作
Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作 Android Application Development 賴 槿 峰 (Chin-Feng Lai) Assistant Professor, institute of CSIE, National Ilan University Nov. 10 th 2011 2011 MMN Lab. All Rights Reserved
4. The Android System
4. The Android System 4. The Android System System-on-Chip Emulator Overview of the Android System Stack Anatomy of an Android Application 73 / 303 4. The Android System Help Yourself Android Java Development
Android Setup Phase 2
Android Setup Phase 2 Instructor: Trish Cornez CS260 Fall 2012 Phase 2: Install the Android Components In this phase you will add the Android components to the existing Java setup. This phase must be completed
Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 2 Android Platform. Marco Picone - 2012
Android Development Lecture 2 Android Platform Università Degli Studi di Parma Lecture Summary 2 The Android Platform Dalvik Virtual Machine Application Sandbox Security and Permissions Traditional Programming
PubMatic Android SDK. Developer Guide. For Android SDK Version 4.3.5
PubMatic Android SDK Developer Guide For Android SDK Version 4.3.5 Nov 25, 2015 1 2015 PubMatic Inc. All rights reserved. Copyright herein is expressly protected at common law, statute, and under various
How To Develop An Android App On An Android Device
Lesson 2 Android Development Tools = Eclipse + ADT + SDK Victor Matos Cleveland State University Portions of this page are reproduced from work created and shared by Googleand used according to terms described
TUTORIALS AND QUIZ ANDROID APPLICATION SANDEEP REDDY PAKKER. B. Tech in Aurora's Engineering College, 2013 A REPORT
TUTORIALS AND QUIZ ANDROID APPLICATION by SANDEEP REDDY PAKKER B. Tech in Aurora's Engineering College, 2013 A REPORT submitted in partial fulfillment of the requirements for the degree MASTER OF SCIENCE
Frameworks & Android. Programmeertechnieken, Tim Cocx
Frameworks & Android Programmeertechnieken, Tim Cocx Discover thediscover world atthe Leiden world University at Leiden University Software maken is hergebruiken The majority of programming activities
Tutorial on Basic Android Setup
Tutorial on Basic Android Setup EE368/CS232 Digital Image Processing, Spring 2015 Windows Version Introduction In this tutorial, we will learn how to set up the Android software development environment
Download and Installation Instructions. Android SDK and Android Development Tools (ADT)
Download and Installation Instructions for Android SDK and Android Development Tools (ADT) on Mac OS X Updated October, 2012 This document will describe how to download and install the Android SDK and
Android Application Development - Exam Sample
Android Application Development - Exam Sample 1 Which of these is not recommended in the Android Developer's Guide as a method of creating an individual View? a Create by extending the android.view.view
Running a Program on an AVD
Running a Program on an AVD Now that you have a project that builds an application, and an AVD with a system image compatible with the application s build target and API level requirements, you can run
Android Development Tutorial. Human-Computer Interaction II (COMP 4020) Winter 2013
Android Development Tutorial Human-Computer Interaction II (COMP 4020) Winter 2013 Mobile OS Symbian ios BlackBerry Window Phone Android. World-Wide Smartphone Sales (Thousands of Units) Android Phones
Android Quiz App Tutorial
Step 1: Define a RelativeLayout Android Quiz App Tutorial Create a new android application and use the default settings. You will have a base app that uses a relative layout already. A RelativeLayout is
Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.
Android: Setup Hello, World: Android Edition due by noon ET on Wed 2/22 Ingredients. Android Development Tools Plugin for Eclipse Android Software Development Kit Eclipse Java Help. Help is available throughout
Lab 1 (Reading Sensors & The Android API) Week 3
ECE155: Engineering Design with Embedded Systems Winter 2013 Lab 1 (Reading Sensors & The Android API) Week 3 Prepared by Kirill Morozov version 1.1 Deadline: You must submit the lab to the SVN repository
AntiAircraft - Android tutorial
AntiAircraft - Android tutorial 1 Introduction The goal of this tutorial is to show how to realize Android application from a very pragmatic point of view. For this purpose, I will assume that the reader
Jordan Jozwiak November 13, 2011
Jordan Jozwiak November 13, 2011 Agenda Why Android? Application framework Getting started UI and widgets Application distribution External libraries Demo Why Android? Why Android? Open source That means
Fahim Uddin http://fahim.cooperativecorner.com [email protected]. 1. Java SDK
PREPARING YOUR MACHINES WITH NECESSARY TOOLS FOR ANDROID DEVELOPMENT SEPTEMBER, 2012 Fahim Uddin http://fahim.cooperativecorner.com [email protected] Android SDK makes use of the Java SE
Location-Based Services Design and Implementation Using Android Platforms
Location-Based Services Design and Implementation Using Android Platforms Wen-Chen Hu Department of Computer Science University of North Dakota Grand Forks, ND 58202 [email protected] Hung-Jen Yang Department
With a single download, the ADT Bundle includes everything you need to begin developing apps:
Get the Android SDK The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android. The ADT bundle includes the essential Android SDK components
A software stack for mobile devices:
Programming Mobile Applications for Android Handheld Systems - Week 1 1 - Introduction Today I am going to introduce you to the Android platform. I'll start by giving you an overview of the Android platform,
Setting up Sudoku example on Android Studio
Installing Android Studio 1 Setting up Sudoku example on Android Studio Installing Android Studio Android Studio provides everything you need to start developing apps for Android, including the Android
Android App Development Lloyd Hasson 2015 CONTENTS. Web-Based Method: Codenvy. Sponsored by. Android App. Development
Android App Lloyd Hasson 2015 Web-Based Method: Codenvy This tutorial goes through the basics of Android app development, using web-based technology and basic coding as well as deploying the app to a virtual
Android Basics. Xin Yang 2016-05-06
Android Basics Xin Yang 2016-05-06 1 Outline of Lectures Lecture 1 (45mins) Android Basics Programming environment Components of an Android app Activity, lifecycle, intent Android anatomy Lecture 2 (45mins)
Home Course Catalog Schedule Pricing & Savings Training Options Resources About Us
1 of 14 12/04/2012 06:46 PM Hello, Jonathan Earl My Account Logout GS-35F-0556S CONTACT US Search TOLL FREE 877-932-8228 Home Course Catalog Schedule Pricing & Savings Training Options Resources About
The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.
Installing the SDK This page describes how to install the Android SDK and set up your development environment for the first time. If you encounter any problems during installation, see the Troubleshooting
Mobile Application Development Android
Mobile Application Development Android MTAT.03.262 Satish Srirama [email protected] Goal Give you an idea of how to start developing Android applications Introduce major Android application concepts
Android Mobile App Building Tutorial
Android Mobile App Building Tutorial Seidenberg-CSIS, Pace University This mobile app building tutorial is for high school and college students to participate in Mobile App Development Contest Workshop.
buzztouch for Android
buzztouch for Android A User s Guide By GoNorthWest June 2012 1 Table of Contents 1. Welcome! 2. Sign Up For buzztouch 3. Basic Hardware and Software Requirements 4. Setting Up Your Android Development
Hacking your Droid ADITYA GUPTA
Hacking your Droid ADITYA GUPTA adityagupta1991 [at] gmail [dot] com facebook[dot]com/aditya1391 Twitter : @adi1391 INTRODUCTION After the recent developments in the smart phones, they are no longer used
Android Programming: Installation, Setup, and Getting Started
2012 Marty Hall Android Programming: Installation, Setup, and Getting Started Originals of Slides and Source Code for Examples: http://www.coreservlets.com/android-tutorial/ Customized Java EE Training:
Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02
Tutorial: Android Object API Application Development SAP Mobile Platform 2.3 SP02 DOCUMENT ID: DC01939-01-0232-01 LAST REVISED: May 2013 Copyright 2013 by Sybase, Inc. All rights reserved. This publication
Developing apps for Android OS: Develop an app for interfacing Arduino with Android OS for home automation
Developing apps for Android OS: Develop an app for interfacing Arduino with Android OS for home automation Author: Aron NEAGU Professor: Martin TIMMERMAN Table of contents 1. Introduction.2 2. Android
Installing Java 5.0 and Eclipse on Mac OS X
Installing Java 5.0 and Eclipse on Mac OS X This page tells you how to download Java 5.0 and Eclipse for Mac OS X. If you need help, Blitz [email protected]. You must be running Mac OS 10.4 or later
23442 ECE 09402 7 Introduction to Android Mobile Programming 23442 ECE 09504 7 Special Topics: Android Mobile Programming
23442 ECE 09402 7 Introduction to Android Mobile Programming 23442 ECE 09504 7 Special Topics: Android Mobile Programming Mondays 5:00 PM to 7:45 PM SJTP, Room 137 Portions From Android Programming The
Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna SDK and initial setup: Outline Ø Today: How
Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release 12.0.3.0.0
Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release 12.0.3.0.0 Part No. E52543-01 April 2014 Oracle Financial Services Software Limited Oracle Park Off Western Express Highway
Introduction to Android Development
2013 Introduction to Android Development Keshav Bahadoor An basic guide to setting up and building native Android applications Science Technology Workshop & Exposition University of Nigeria, Nsukka Keshav
