Android code , Android Phone, Android Developers

Android code , Android Phone, Android Developers and New Google Android Technologies

Archive for September, 2010

Android Manifest File

Posted by admin September - 28 - 2010 - Tuesday ADD COMMENTS

AndroidManifest.xml

The AndroidManifest.xml file is where your global settings are made. If you are an ASP.NET developer, you can think of AndroidManifest.xml as Web.config and Global.asax rolled into one. (If you are not an ASP.NET developer, this means that AndroidManifest.xml is a place for storing settings.) AndroidManifest.xml will include such settings as application permissions, Activities, and intent filters.

The standard AndroidManifest.xml file should contain the following information:

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package=”testPackage.HelloWorldText”>
<application android:icon=”@drawable/icon”>
<activity android:label=”@string/app_name”>
<intent-filter>
<action android:value=”android.intent.action.MAIN” />
<category android:value=”android.intent.category.LAUNCHER”
/>
</intent-filter>
</activity>
</application>
</manifest>
As you create future applications, you will be adding information to this file. Notice that the package name you supplied is listed here, as well as the action that your Activity will handle.

Referenced Libraries

A list of the Referenced Libraries is also included in the root of the project. Typically, for a beginner project, you should see only one library here. Expand the Referenced Libraries branch and examine its contents, the libraries that are currently referenced by your application project. Given that this is a new Android project, you will see one library in your project’s references, android.jar, the Android SDK. (If you are familiar with the Java SDK, android.java is analogous to Java’s rt.java file, containing many of the Java APIs found in rt.java.) The Android plugin ensures that this file is the only library referenced by your application. The application needs to reference the SDK to gain access to all the classes contained in the SDK libraries, such as your Views, Controls, and even the Google API.

CAUTION
Eclipse enables you to add other user-defined libraries and external classes to your project’s references. However, unless you are sure that those external references will work with your Android application (and thus on the Android platform), you should think twice before you add them.

Android running on the iPhone 3G!

Posted by admin September - 27 - 2010 - Monday ADD COMMENTS
YouTube Preview Image

Examining the Android-Created Files

Posted by admin September - 24 - 2010 - Friday ADD COMMENTS

This section discusses the new files that Android has just created for you. A fairly robust structure has been created for you, and if you do not know what you are looking at, you may end up putting some code in places that you should not. There are files provided by Android that you need to modify, and there are ones that you should not modify; knowing the difference may save you from having to re-create your project. With your new application project open, take a look at the Package Explorer, one of two tabs located in the pane to the left of the main development area. The following illustration shows what the Package Explorer should look like.

NOTE

If the Package Explorer is not open, you can activate it by choosing Window | Show View | Package Explorer.
You should see a root directory, in this case named HelloWorldText. The root directory is the home, or repository, for all of your project files. Both your user-created files and the Android auto-generated files will be placed in the directory, easily accessible from the Package Explorer. Currently there should be a few items in your root directory: an AndroidManifest.xml file, a package included in the Referenced Libraries, and three directories (res, assets, and src). These items are discussed in turn next.

CAUTION

Posted by admin September - 22 - 2010 - Wednesday ADD COMMENTS

The package name adheres to the standard Java package-naming guidelines, which were established to lower the risk of two packages being released with the same name. The top level of the package name is the domain identifier of the company (com, org,and net are examples). This is followed by the domain name, such as google. Finally, a descriptive title for the contents of the package is provided. For purposes of this post, my package name for the Hello World! application will omit “com” to identify that it is a text application and not meant to be published. All future packages created in this book will be publishable and use the com identifier. For the HelloWorldText application, use the package name android_programmers_guide.HelloWorldText. This name uniquely identifies the code that belongs to this application and differentiates this test application from others you will develop in this book.

CAUTION
If you are paying attention to the screen as you are typing, you will notice that an error message appears at the top of the wizard as you enter the package name, stating that you must fill out all the fields properly to continue. This error message is premature and can be a bit confusing because you have not even attempted to fill out the other fields in the Properties area. If you see such an error message, just ignore it and continue on and complete the next two fields in Properties area.

The next Properties field, Activity Name, is required because it is the reference to the main screen of your application. That is, think of the Activity as the “window” within which your application is displayed. Without an Activity, your application would not do very much. However, because Android applications can be composed of several Activities, the New Android Project wizard needs to know which Activity will be the default. Activity Name is a required field and has no default, so you must supply one to continue (as indicated in the preceding caution).

For purposes of this example, use HelloWorldText. This keeps the application simple and is just about as descriptive as it needs to be for the moment. The final Properties field, Application Name, specifies the name of your application. This is the name that will be used to manage your application when it is installed on the device. Again, for the sake of keeping things simple, go with HelloWorldText as the application name. The following illustration shows the completed New Android Project wizard.

android code

TIP
The Application Name and the Activity Name fields do not have to match. In fact, many programmers are used to the older conventions whereby the “starting” screen of an application is usually called Main or Startup. Use whatever conventions you are comfortable with. For purposes of demonstration, this post assumes that you are using the names suggested.
Click Finish to kick off the creation process. The wizard runs a background process that facilitates the auto-generation of some required files, and the setup of the directory structure needed to support an Android application. When the process is complete, you
will have your first Android application project.

caution for android code

TIP
If the Finish button is not available to you, you may have made an error in one of the fields in the Properties area. To ensure that the Properties fields are correctly filled in, Eclipse will not allow you to finish the process if any of the information that you entered may cause problems. Go back and make sure that all of the Properties fields are correctly filled in. The next section examines the contents of the auto-generated Android files and the purpose of some of the shell items for your application.

Android – Apps without borders

Posted by admin September - 20 - 2010 - Monday ADD COMMENTS
YouTube Preview Image

Creating Your First Android Project in Eclipse Part III

Posted by admin September - 18 - 2010 - Saturday ADD COMMENTS

In addition, the New Android Project wizard contains a few options, shown next, that you must set to initiate your Android project.

For the Project Name field, for purposes of this example, use the title HelloWorldText. This name sufficiently distinguishes this Hello World! project from the others that you will be creating in this Post. In the Contents area, keep the default selections: the Create New Project in Workspace radio button should be selected and the Use Default Location check box should be checked. This will allow Eclipse to create your project in your default workspace directory. The advantage of keeping the default options is that your projects are kept in a central location, which makes ordering, managing, and finding these projects quite easy. For example, if you are working in a Unix-based environment, this path points to your $HOME directory.

If you are working in a Microsoft Windows environment, the workspace path will be C:/Users/<username>/workspace, as shown in the previous illustration. However, for any number of reasons, you may want to uncheck the Use Default Location check box and select a different location for your project. One reason you may want to specify a different location here is simply if you want to choose a location for this specific project that is separate from other Android projects. For example, you may want to keep the projects that you create in this book in a different location from projects that you create in the future on your own. If so, simply override the Location option to specify your own custom location directory for this project.

On the other hand, you may be required to specify a project location if you did not check the Use This as the Default and Do Not Ask Again check box in the Select a Default Workspace dialog box during the Eclipse setup (as recommended in the last section of Post 2). Checking that box during the Eclipse setup defaults all new projects to the workspace directory (and provides the default location shown in the Location field of the New Android Project wizard). If you did not check this box during the Eclipse setup process, you need to select a path for your new project now by clicking the Browse button and navigating to it. The final three options in the New Android Project wizard are in the Properties area.
These properties define how your project is integrated into the Android environment. In the Package Name field, you specify the namespace given to your application package. For example, android.app.Activity or com.google.android.map.MapActivity.

Creating Your First Android Project in Eclipse Part II

Posted by admin September - 9 - 2010 - Thursday ADD COMMENTS

Creating Your First Android Project in Eclipse To start your first Android project, open Eclipse. When you open Eclipse for the first time, it opens to an empty development environment (see Figure 5-1), which is where you want to begin. Your first task is to set up and name the workspace for your application. Choose File | New | Android Project, which will launch the New Android Project wizard.

CAUTION

Do not select Java Project from the New menu. While Android applications are written in Java, and you are doing all of your development in Java projects, this option will create a standard Java application. Selecting Android Project enables you to create Android-specific applications. If you do not see the option for Android Project, this indicates that the Android plugin for Eclipse was not fully or correctly installed. Review the procedure in Post for installing the Android plugin for Eclipse to correct this. The New Android Project wizard creates two things for you:

  1. A shell application that ties into the Android SDK, using the android.jar file, and ties the project into the Android Emulator. This allows you to  code using all of the Android libraries and packages, and also lets you debug your applications in the proper environment.
  2. Your first shell files for the new project. These shell files contain some of the vital application blocks upon which you will be building your  programs. In much the same way as creating a Microsoft .NET application in Visual Studio generates some Windows-created program code in  your files, using the Android Project wizard in Eclipse generates your initial program files and some Android-created code.

Antenna Repair Diagnose reception problems & repair your existing antenna issues with the help of Jim’s Antenna services.

SEO Company Top Rated SEO Company providing internet marketing to successful businesses in the U.S.

Internet Advertising Houstonelectronics online store indiaAlarm Battery