Full Tutorial on android application developer by Suhan Gorya
Kamis, 17 Oktober 2013
0
komentar
Suhan Gorya
This time i come with the tutorial, about how to make new Android application,
if any problem or error occurred during the programming tutorial, just tell me or E-mail me, will reply you with solution.
so now try it, surely you will feel good to be application developer, here is the steps, simply follow the tutorial given as:
1. What You Need to Begin
Because Android applications run within the Dalvik VM, you can write them on any platform that
supports the developer tools. This currently includes the following
a. Microsoft Windows (XP or later)
b. Mac OS X 10.5.8 or later (Intel chips only)
c. Linux (including GNU C Library 2.7 or later)
2. To get started, you’ll need to download and install the following:
1.The Android SDK starter package
2.Java Development Kit (JDK) 5 or 6
You can download the latest JDK from Sun at http://java.sun.com/javase/downloads/index.jsp.
3. Downloading and Installing the Android SDK
There’s no cost to download or use the API, and Google doesn’t require your application to pass a review to distribute your finished programs on the Google Play Store. Although the Google PlayStore requires a small one-time fee to publish applications, if you chose not to distribute via the Google Play Store, you can do so at no cost.
You can download the latest version of the SDK starter package for your chosen development platform from the Android development home page at
http://developer.android.com/sdk/index.html
Unless otherwise noted, the version of the Android SDK used for writing this was version 4.3 (API level 18).
As an open-source platform, the Android SDK source is also available for you to
download and compile from http://source.android.com.
The starter package is a ZIP fi le that contains the latest version of the Android tools required to
download the rest of the Android SDK packages. Install it by unzipping the SDK into a new folder.
Take note of this location, as you’ll need it later.
If you are developing from a Windows platform, an executable Windows installer is available (and recommended) as an alternative to the ZIP fi le for installing the platform tools.
Before you can begin development, you need to download at least one SDK platform release. You can do this on Windows by running the SDK Manager.exe executable, or on Mac OS or Linux by running the “android’’ executable in the tools subfolder of the starter package download.
The screen that appears (see Figure-1) shows each of the packages available for the download. This includes a node for the platform tools, each of the platform releases, and a collection of extras, such as the Android Support Package and billing/licensing packages.
FIGURE-1
You can expand each platform release node to see a list of the packages included within it, including the tools, documentation, and sample code packages.
To get started, simply check the boxes corresponding to the newest framework SDK and the latest
version of the tools, compatibility/support library, documentation, and sample code.
FIGURE-1
For testing the backward compatibility of your applications, it can often be useful
to download the framework SDK for each version you intend to support.
To use the Google APIs (which contain the Maps APIs), you also need to select the Google APIs by
Google package from the platform releases you want to support.
When you click the Install Packages button, the packages you’ve chosen will be downloaded to your SDK installation folder. The result is a collection of framework API libraries, documentation, and several sample applications.
The examples included in the SDK are well documented and are an excellent
source for full, working examples of applications written for Android. When you
fi nish setting up your development environment, it’s worth going through them.
Downloading and Installing Updates to the SDK As new versions of the Android framework SDK, developer tools, sample code, documentation,compatibility library, and third-party add-ons become available, you can use the Android SDK Manager to download and install those updates.
All future packages and upgrades will be placed in the same SDK location.
4. Developing with Eclipse
The examples and step-by-step instructions in this tutorial are targeted at developers using Eclipse with the Android Developer Tools (ADT) plug-in. Neither is required, though; you can use any text editor or Java IDE you’re comfortable with and use the developer tools in the SDK to compile, test, and debug the code snippets and sample applications.
As the recommended development platform, using Eclipse with the ADT plug-in for your Android development offers some significant advantages, primarily through the tight integration of many of the Android build and debug tools into your IDE.
Eclipse is a particularly popular open-source IDE for Java development. It’s available for download for each of the development platforms supported by Android (Windows, Mac OS, and Linux) from the Eclipse foundation (www.eclipse.org/downloads).
Many variations of Eclipse are available, with Eclipse 3.5 (Galileo) or above required to use
the ADT plugin. The following is the configuration for Android used in the preparation of
this tutorial:
a. Eclipse 3.7 (Indigo) (Eclipse Classic download)
b. Eclipse Java Development Tools (JDT) plug-in
c. Web Standard Tools (WST)
The JDT plug-in and WST are included in most Eclipse IDE packages.
Installing Eclipse consists of uncompressing the download into a new folder, and then running the eclipse executable. When it starts for the fi rst time, you should create a new workspace for your Android development projects.
Using the Android Developer Tools Plug-In for Eclipse The ADT plug-in for Eclipse simplifi es your Android development by integrating the developer tools, including the Emulator and .class-to-.dex converter, directly into the IDE. Although you don’t have to use the ADT plug-in, it can make creating, testing, and debugging your applications faster and easier.
The ADT plug-in integrates the following into Eclipse:
a. An Android Project Wizard, which simplifies creating new projects and includes a basic
application template
b. Forms-based manifest, layout, and resource editors to help create, edit, and validate your
XML resources
c. Automated building of Android projects, conversion to Android executables (.dex), packaging to package fi les (.apk), and installation of packages onto Dalvik VMs (running both
within the Emulator or on physical devices)
d. The Android Virtual Device manager, which lets you create and manage virtual devices to
host Emulators that run a specifi c release of the Android OS and with set hardware and
memory constraints
e. The Android Emulator, including the ability to control the Emulator’s appearance and network
connection settings, and the ability to simulate incoming calls and SMS messages
f. The Dalvik Debug Monitoring Service (DDMS), which includes port forwarding, stack, heap,
and thread viewing, process details, and screen-capture facilities
g. Access to the device or Emulator’s fi lesystem, enabling you to navigate the folder tree and
transfer fi les
h. Runtime debugging, which enables you to set breakpoints and view call stacks
i. All Android/Dalvik log and console outputs
5.Installing the ADT Plug-In
Install the ADT plug-in by following these steps:1. Select Help Í Install New Software from within Eclipse.
2. In the Available Software dialog box that appears, click the Add button.
3. In the next dialog, enter a name you will remember (e.g., Android Developer Tools) into the
Name fi eld, and paste the following address into the Location text entry box:
https://dl-ssl.google.com/android/eclipse/
4. Press OK and Eclipse searches for the ADT plug-in. When fi nished, it displays the available
plug-ins, as shown in Figure 2-3. Select it by clicking the check box next to the Developer
Tools root node, and then click Next.
FIGURE 2
5. Eclipse now downloads the plug-in. When it finishes, a list of the Developer Tools displays
for your review. Click Next.
6. Read and accept the terms of the license agreement, and click Next and then Finish. As the
ADT plug-in is not signed, you’ll be prompted before the installation continues.
7. When installation is complete, you need to restart Eclipse and update the ADT preferences.
Restart and select Window Í Preferences (or Eclipse Í Preferences for Mac OS).
8. Select Android from the left panel.
9. Click Browse, navigate to the folder into which you installed the Android SDK, and then
click Apply. The list updates to display each available SDK target.
Click OK to complete the SDK installation.
6. Updating the ADT Plug-In
In most cases, you can update your ADT plug-in simply as follows:
1. Navigate to Help Í Check for Updates.
2. If there are any ADT updates available, they will be presented. Simply select them and choose
Install.
Sometimes a plug-in upgrade may be so signifi cant that the dynamic update mechanism
can’t be used. In those cases you may have to remove the previous plug-in
completely before installing the newer version, as described in the previous section.
Using the Support Package
The support library package (previously known as the compatibility library) is a set of static libraries that you can include as part of your projects to gain either convenience APIs that aren’t packaged as part of the framework (such as the View Pager), or useful APIs that are not available on all platform releases (such as Fragments).
The support package enables you to use framework API features that were introduced in recent
Android platform releases on any device running Android 1.6 (API level 4) and above. This helps you provide a consistent user experience and greatly simplifi es your development process by reducing the burden of supporting multiple platform versions.
1. Add a new /libs folder in the root of your project hierarchy.
2. Copy the support library JAR fi le from the /extras/android/support/ folder in your
Android SDK installation location.
You’ll note that the support folder includes multiple subfolders, each of which represents
the minimum platform version supported by that library. Simply use the corresponding JAR
fi le stored in the subfolder labeled as less than or equal to the minimum platform version
you plan to support.
For example, if you want to support all platform versions from Android 1.6 (API level 4)
and above, you would copy v4/android-support-v4.jar.
3. After copying the file into your project’s /libs folder, add it to your project build path by
right-clicking in the Package Explorer and selecting Build Path Í Add to Build Path.
7. Creating Your First Android Application
You’ve downloaded the SDK, installed Eclipse, and plugged in the plug-in. You are now ready to start programming for Android. Start by creating a new Android project and setting up your Eclipse run and debug confi gurations, as described in the following sections.
Creating a New Android Project
To create a new Android project using the Android New Project Wizard, do the following:
1. Select File Í New Í Project.
2. Select the Android Project application type from the Android folder, and click Next.
3. In the wizard that appears, enter the details for your new project. On the fi rst page
(Figure 3), the Project Name is the name of your project fi le. You can also select the location
your project should be saved.
4. The next lets you select the build target for your application. The build target is the version of the Android framework SDK that you plan to develop with. In addition
to the open sourced Android SDK libraries available as part of each platform release, Google
offers a set of proprietary APIs that offer additional libraries (such as Maps). If you want to
use these Google-specific APIs, you must select the Google APIs package corresponding to the platform release you want to target.
Your project’s build target does not need to correspond to its minimum SDK or
target SDK. For new projects it’s good practice to build against the newest version
of the SDK to take advantage of effi ciency and UI improvements in newer platform releases.
5. The final step allows you to specify the application properties. The Application
Name is the friendly name for your application; the Package Name specifies its Java package;
the Create Activity option lets you specify the name of a class that will be your initial
Activity; and setting the Minimum SDK lets you specify the minimum version of the SDK
that your application will run on.
Selecting the minimum SDK version requires you to choose the level of backward
compatibility you want to support to target a wider group of Android devices.
Your application will be available from the Google Play Store on any device
running the specifi ed build or higher.
At the time of this writing, more than 98% of Android devices were running
at least Android 2.1 (API level 7). The latest Ice Cream Sandwich SDK is
4.3 (API level 18).
6. When you’ve entered the details, click Finish.
If you selected Create Activity, the ADT plug-in will create a new project that includes a class that extends Activity. Rather than being completely empty, the default template implements Hello World. Before modifying the project, take this opportunity to confi gure launch
configurations for running and debugging.
Creating an Android Virtual Device
AVDs are used to simulate the hardware and software confi gurations of different Android devices, allowing you test your applications on a variety of hardware platforms.
There are no prebuilt AVDs in the Android SDK, so without a physical device, you need to create at least one before you can run and debug your applications.
1. Select Window Í AVD Manager (or select the AVD Manager icon on the Eclipse toolbar).
2. Select the New... button.
The resulting Create new Android Virtual Device (AVD) dialog allows you to confi gure a
name, a target build of Android, an SD card capacity, and device skin.
3. Create a new AVD called “My_AVD” that targets Android 4.0.3, includes a 16MB SD Card,
and uses the Galaxy Nexus skin, as shown in Figure 2-8.
4. Click Create AVD and your new AVD will be created and ready to use.
Creating Launch Confi gurations
Launch confi gurations let you specify runtime options for running and debugging applications.
Using a launch confi guration you can specify the following:
a. The Project and Activity to launch
b. The deployment target (virtual or physical device)
c. The Emulator’s launch parameters
d. Input/output settings (including console defaults)
You can specify different launch configurations for running and debugging applications. The following
steps show how to create a launch configuration for an Android application:
1. Select Run Configurations… or Debug Configurations… from the Run menu.
2. Select your application from beneath the Android Application node on the project type list,
or right-click the Android Application node and select New.
3. Enter a name for the configuration. You can create multiple configurations for each project,
so create a descriptive title that will help you identify this particular setup.
4. Choose your start-up options. The first (Android) tab lets you select the project to run and
the Activity that you want to start when you run (or debug) the application. Figure 2-9
shows the settings for the project you created earlier.
5. Use the Target tab, as shown in Figure 2-10, to select the default virtual device to launch on,
or select Manual to select a physical or virtual device each time you run the application. You
can also confi gure the Emulator’s network connection settings and optionally wipe the user
data and disable the boot animation when launching a virtual device.
The Android SDK does not include a default AVD, so you need to create one
before you can run or debug your applications using the Emulator. If the Virtual
Device selection list in Figure 2-10 is empty, click Manager... to open the Android
Virtual Device Manager and create one as described in the previous section.
Further details on the Android Virtual Device Manager are available later in this
chapter.
6. Set any additional properties in the Common tab.
7. Click Apply, and your launch configuration will be saved.
8. Running and Debugging Your Android Application
You’ve created your first project and created the run and debug confi gurations for it. Before making any changes, test your installation and confi gurations by running and debugging the Hello World project.
From the Run menu, select Run or Debug to launch the most recently selected confi guration, or
select Run Configurations… or Debug Configurations… to select a specific configuration.
If you’re using the ADT plug-in, running or debugging your application does the following:
a. Compiles the current project and converts it to an Android executable (.dex)
b. Packages the executable and your project’s resources into an Android package (.apk)
c. Starts the virtual device (if you’ve targeted one and it’s not already running)
d. Installs your application onto the target device
e. Starts your application
If you’re debugging, the Eclipse debugger will then be attached, allowing you to set breakpoints and debug your code.
If everything is working correctly, you’ll see a new Activity running on the device or in the
Emulator,
Understanding Hello World
Take a step back and have a good look at your fi rst Android application.
Activity is the base class for the visual, interactive components of your application; it is roughly
equivalent to a Form in traditional desktop development
“Creating Applications and Activities”).
Hello World
package suhan.gorya.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class MyActivity extends Activity {
/** Called when the Activity is first created. **/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
code snippet Suhan_gorya_HelloWorld/src/MyActivity.java
In Android, visual components are called Views, which are similar to controls in traditional desktop development. The Hello World template created by the wizard overrides the onCreate method to call setContentView, which lays out the UI by infl ating a layout resource, as highlighted in bold in the following snippet:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
The resources for an Android project are stored in the res folder of your project hierarchy, which
includes layout, values, and a series of drawable subfolders. The ADT plug-in interprets these
resources to provide design-time access to them through the R variable,
Listing shows the UI layout defined in the main.xml file created by the Android project template
and stored in the project’s res/layout folder.
LISTING Hello World layout resource
<?xml version=”1.0” encoding=”utf-8”?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello”
/>
</LinearLayout>
code snippet Suhan_Gorya_HelloWorld/res/layout/main.xml
Defining your UI in XML and infl ating it is the preferred way of implementing your user interfaces (UIs), as it neatly decouples your application logic from your UI design.
To get access to your UI elements in code, you add identifi er attributes to them in the XML definition.You can then use the findViewById method to return a reference to each named item. The following XML snippet shows an ID attribute added to the Text View widget in the Hello World template:
<TextView
android:id=”@+id/myTextView”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello”
/>
And the following snippet shows how to get access to it in code:
TextView myTextView = (TextView)findViewById(R.id.myTextView);
Alternatively (although it’s not generally considered good practice), you can create your layout
directly in code, as shown in Listing
LISTING : Creating layouts in code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout.LayoutParams lp;
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
LinearLayout.LayoutParams textViewLP;
textViewLP = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TextView myTextView = new TextView(this);
myTextView.setText(getString(R.string.hello));
ll.addView(myTextView, textViewLP);
this.addContentView(ll, lp);
}
code snippet Suhan_gorya_Manual_Layout/src/MyActivity.java
All the properties available in code can be set with attributes in the XML layout.
More generally, keeping the visual design decoupled from the application code helps keep the code concise. With Android available on hundreds of different devices of varying screen sizes, defining your layouts as XML resources makes it easier for you to include multiple layouts optimized for different screens.
So far this is the end of the todays tutorial ,
create and enjoy the application,,
if any error occur just tweet me or comment,
enjoy.
Suhan Gorya
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Full Tutorial on android application developer by Suhan Gorya
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke http://androidapple7.blogspot.com/2013/10/full-tutorial-on-android-application.html. Terima kasih sudah singgah membaca artikel ini.Ditulis oleh Unknown
Rating Blog 5 dari 5
0 komentar:
Posting Komentar