Working with Android:
• Use Update Manager feature of your Eclipse installation to install the latest revision of ADT on your development computer. Launch Eclipse environment.
• Start Eclipse, then select Help > Install New Software
• The dialog that appears, click the Available Software tab.
• Click on Add Site button, In the Add Site dialog that appears, enter this URL in the "Location" field https://dl-ssl.google.com/android/eclipse/ and Name into Name Field
• Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
• In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
• Installing windows will look like this
• Restart your Eclipse environment
• Download SDK from herehttp://developer.android.com/sdk/index.html
Configuring the ADT Plug-in
• Select Window > Preferences... to open the Preferences panel.
• Select Android from the left panel.
• For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.
• Click Apply, and then OK.
Adding Android Platforms and Other Components
Before adding SDK components disable your antivirus services.
• Goto Windows>> Android SDK and AVD Manager
• Launch Android SDK and AVD Manager
• Click on Available Packages
• Select following options:
1. Documentation for Android SDK, API 8, revision 1
2. SDK Platform Android 2.2 API revision 2
3. Samples for SDK API 8, revision1
4. Google API by Google Inc., Android API 8, revesion 2
5. USB Driver Package revision 3
6. Market Licensing Package, revision 3
• And click on Install Selected button.
• Click on Install button.
Creating an Android Project
The ADT plug-in provides a New Project Wizard that you can use to quickly create a new Android project.
• Select File > New > Project
• Select Android > Android Project, and click Next.
• Select the contents for the project:
1. Enter a Project Name. This will be the name of the folder where your project is created.
2. Under Contents, select Create new project in workspace. Select your project workspace location.
3. Under Target, select an Android target to be used as the project's Build Target. The Build Target specifies which Android platform you'd like your application built against.
• Under Properties, fill in all necessary fields.
1. Enter an Application name. This is the human-readable title for your application — the name that will appear on the Android device.
2. Enter a Package name. This is the package namespace (following the same rules as for packages in the Java programming language) where all your source code will reside.
3. Select Create Activity (optional, of course, but common) and enter a name for your main Activity class.
4. Enter a Min SDK Version.
• Click on Finish button.
• Once you complete the New Project Wizard, ADT creates the folders and files in your new project.
Creating an AVD
An Android Virtual Device (AVD) is a device configuration for the emulator that allows you to model real world devices. In order to run an instance of the emulator, you must create an AVD.
• Select Window > Android SDK and AVD Manager.
• Click New to create a new AVD.
• Fill in the details for the AVD.
• Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
• Click on Create AVD.
Running on the emulator
• To run your application, select Run > Run from the Eclipse menu bar.
• Right click on package com.core and select New>>Class
‘Hello World’ example on Android:
a. Launch Eclipse
b. Create a new Android project, from New>> Other menu option, select ‘Android Project’
c. Fill in the project details with the following values:
• Project name: HelloAndroid
• Application name: Hello, Android
• Package name: com.example.helloandroid (or your own private namespace)
• Create Activity: HelloAndroid
Click Finish.
d. Here is a description of each field:
Project Name
This is the Eclipse Project name — the name of the directory that will contain the project files.
Application Name
This is the human-readable title for your application — the name that will appear 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 will be 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 will be generated by the plugin. This will be 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.
Min SDK Version
This value specifies the minimum API Level required by your application. 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 will be generated and stored. "Build Target" is the platform target that your application will be compiled against (this should be selected automatically, based on your Min SDK Version).
e. 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:
f. Replace all the above code with the following:
package com.example.helloandroid;
import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class HelloAndroid extends Activity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);TextView tv = new TextView(this);tv.setText("Hello, Android");setContentView(tv);}}
g. Before running the code, do the following sub-steps:
i. Open a notepad, right the below codes into it:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.example.tests;public final class R {public static final class attr {}public static final class drawable {public static final int icon=0x7f020000;}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;}}
See the below screen:ii. Save the notepad with R.java,
Now Go into your Eclipse’s workspace >> Project name (in current case ‘HelloAndroid’)>> gen folder
>> Create a sub folder com under gen
>> Create a sub folder example under com
>> Create a sub folder helloandroid under example
Paste R.java into created sub folder helloandroid
h. The Eclipse plugin makes it easy to run your applications:
I. Select Run > Run
II. Select "Android Application".
See the above screen, in which I have created a new configuration “TestAnd1” under Android Application,
Click Run,
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 plugin installs your application and launches the default Activity. You should now see something like this
Here is the first embedded video file (we have two video files in completion of this post):
SeleniumWithiPhone-part6A
Uploaded by vipingupta. - Technology reviews and science news videos.
Here is the second embedded video file (we have two video files in completion of this post):
SeleniumWithiPhone-part6B
Uploaded by vipingupta. - Explore more science and tech videos.
No comments:
Post a Comment