Android code , Android Phone, Android Developers

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

Hello World! Complete

Posted by admin April - 12 - 2011 - Tuesday ADD COMMENTS

Your next step is to import the package TextView from android.widget. This will
give you access to the TextView and let you create your own instance of it. Place this
code near the top of your current HelloWorldText.java file, where the existing import
statements are
import android.widget.TextView;
Now, create an instance of TextView. By creating the TextView instance, you can use
it to display text to the screen without directly modifying main.xml. Place the following
code after the onCreate( ) statement is fired:
TextView HelloWorldTextView = new TextView(this);

NOTE
TextView takes a handle to the current context as an argument. Pass this to the
TextView to associate it with the current context. If you follow the hierarchy
through the SDK, HelloWorldText extends Activity, which extends
ApplicationContext, which in turn extends Context. This is how you can
pass this to your TextView.
The preceding line creates an instance of TextView named HelloWorldTextView
and then instantiates HelloWorldTextView, by setting it to a new TextView. The new
TextView is passed the context of this to be fully instantiated.
Now that the TextView is defined, you can add your text to it. The following line of
code assigns the text “Hello World!” to the TextView:
HelloWorldTextView.setText(“Hello World!”);
This line lets you set the text of your TextView. setText( ) lets you assign a string to the
TextView.

Your TextView has been created and now contains the message that you want to
display. However, simply passing “Hello World!” to the TextView does not display
anything to the screen. As discussed previously, you need to set the ContentView to

 

display something to the screen. You have to use the following code to set TextView
to the context and display it to the screen:
setContentView(HelloWorldTextView);
Examining this line, you can see that you pass to setContentView your TextView. The
preceding three lines of code are what it takes to make your Hello World! application.
You created a TextView, assigned your text to it, and set it to the screen. All things
considered, this is not very complicated at all.
The full contents of your HelloWorldText.java file should look like the following:
package android_programmers_guide.HelloWorldText;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloWorldText extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
/**Hello World JFD */
/**BEGIN           */
/**Create TextView */
TextView HelloWorldTextView = new TextView(this);
/**Set text to Hello World */
HelloWorldTextView.setText(“Hello World!”);

/**Set ContentView to TextView */
setContentView(HelloWorldTextView);
/**END             */
}
}
Now compile and run your new Hello World! application in the Android Emulator.
Choose Run | Run or press CTRL-F11 to launch the application in the Android Emulator. The following illustration depicts the results of your Hello World! application.

You have just created your first full Android Activity. This small project demonstrated
a fairly common execution of a Hello World! application. You set a TextView to the
Activity’s ContentView and displayed the “Hello World!” message to a cell phone screen
in the Android Emulator. The following section looks at a slightly different way of
implementing Hello World!, using an image. mobile marketing

IP Phone iTel Switch Plus is a carrier grade soft-switch, compatible to all standard VoIP devices. It offers class 4 and class 5 VoIP switch features. iTel billing is real time billing solution for VoIP service providers. iTel provides full suite of mobile VoIP solutions, tunneling and codec conversion products.

Shooting Sleeves For Basketball Shop for the best and huge collection of Sports Products from Jump USA. We offer a wide variety of Shooting Sleeves for Basketball, Shooting Sleeve, Running Speed Parachute, Knee Supports and many more at affordable price. Safe and Secure Shopping with FREE Shipping!

MPLS Discover TelePacific Multi Protocol Label Switching – MPLS our secure, private & efficient business VPN.

Cheap calls to Europe We are dealing international calls. we have the cheapest prices in UK and good voice quality.

Nokia Mobile Price NBPL is a market leader for selling Nokia phone products. You will find all nokia mobiles with latest price information from us. Our Nokia Mobile Price list is a great souce for comparing Nokia phone prices.

Nokia Mobile Nokia mobile phones known as the best quality mobiles in the world.

DISH Network Order Dish Network from Allsat Dishnetwork Affiliate, you not only get the best satellite TV, you also get tons of channels and great service.

Tanning The Handy Tan System Kit is a must try airbrush tanning sprayer.Perfect for airbrush tanning on the go. Get the perfect tan at home.

Web Design Birmingham Web Design & SEO company in Birmingham, West Midlands. Our expertise includes Joomla design, WordPress design and Magento development. Speak to our ecommerce design team or search engine optimisation consultants at Opace for more information.

Software Attorney Law firm focused on representing Software, SAAS, and IT Services companies.

Unlock iphone PATENTED 4.3.2 iPhone Unlock/Jailbreak Software – ***WE HAVE THE ONLY STATISTICALLY PROVEN SOLUTION ON THE INTERNET! Easy One-Click Solution puts our competitors to shame! iPhone 3G/3GS/4 Unlock Jailbreak.

Cellular Phone Service Cellular Phone Service – RebelFone offers on Global Phone, GSM cell phones and unlocked cellular phones also provide cellular phone service.

International Calling Cards International calling cards – get International calling cards from clay.co.in at Save up to 70% on international roaming along with International calling cards, clay also offers prepaid data card, international roaming , Global Travel SIM, Prepaid SIM Card.

Tidal Storage are specialists in Data Storage, protection, virtualisation, backup and SAN Consulting.

man utd tickets Manchester United FC Official Football Tickets are on sale Now. Buy Manchester United Tickets for all home and away games. Manchester United Tickets are on available to buy now!

Covenant Eyes Filtering Software Covenant Eyes Filter gives parents control over how their kids use the Internet. Set time limits, and content limits appropriate for each of your kids. Subscribe using the promotional code ‘onedegree’ and try it free for 30 days!

VOIP Phone Services Get the best VoIP business phone systems, Cisco IP phones and wireless phone system for small business at cost effective prices.

Led Torches Find high quality led torches, flashlights, batteries and related LED accessories in LED Torches Shop Australia.

Cheap International Call Features Tel3Advantage and phone cards for making cheap phone calls from any phone or VoIP and PC Phone for international calling over the internet.

Electronic Components Avnet distributes electronic components, connectors, semiconductors, technology solutions, computer products and embedded technology. Learn more.

Offshore Software Development SynapseIndia is an offshore software development company in India providing high quality custom software development services in various technologies.

RFID Ramp is Australia’s leading RFID Software developer and Systems Integrator.

Chat Line TeleCafe is the most fun & friendly phone chat line in Australia. Girls talk for free!

online colleges Earn online college degrees from the very best colleges and universities listed on this website.

phones for cash Sell your old and used mobile phone. Mazuma Mobile recycle old and used mobile phones for cash. Trade in your old and used mobile phone online now!

Convert PSD to WordPress: We specialize in converting PSD to WordPress themes and PSD to WordPress templates. Get PSD to WordPress theme conversion service at an affordable budget.

Get quality SEO Link Building Firm for high rankings! Link Building Works offers best Quality One Way Link Popularity Services at an affordable budget.

PSD to HTML, XHTML, CSS conversion discussions, reviews, tutorials, slicing/conversion HTML Reviews. XHTML-CSS-code provides slicing tips for designers, html coders, new & old to improve their skills.

Mobile Ad Agency Square One Agency is a mobile marketing and ad agency that offers mobile advertising and commerce along with mobile app development.

Touch Screen Mp3 Player 50 % Discount – Buy online best mp3 player, mp 4 player radio, mp3 4gb fm, touch screen mp3 player fm, 8gig mp3 player at affordable price from electronic store.

Copier Staples We are official Online distributor of branded copier staples. We providing trusted staple brand with affordable price.

Hello World! Again

Posted by admin March - 21 - 2011 - Monday ADD COMMENTS

While I have discussed the existence of this TextView in the xml, I have not yet discussed why it works without any corresponding code. I mentioned earlier in this book hat there are two ways to design a UI for Android: through the code, and through the main.xml file. The preceding code sample creates a TextView in xml and sets the text to “Hello World, HelloWorldText.” Edit this line of the main.xml file to read as follows:
android:text=”This is the text of an Android TextView!”
Rerun the project, and your results should appear as they do in this illustration. Take some time and experiment with the xml TextView.
Then you can move on to another way of creating a Hello World! application.

Hello World! Again
In this section, you will create another Hello World! application for Android. However, this time you will program the UI in code rather than by using the xml file—and you will actually do most of the work. The first step here is to remove the TextView code that is in main.xml. The following section of code represents the TextView. Removing it essentially makes your application an empty shell.
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Hello World, HelloWorldText”
/>

After you have removed the TextView code, your main.xml file should look like this:
<?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”
>
</LinearLayout>
Now that you have a clean main.xml file, and thus a clean application shell, you can
begin to add the code that will display “Hello World!” on the screen. Start by opening the
HelloWorldText.java file and removing the following line:
setContentView(R.layout.main);

NOTE
You still need to set a ContentView for your new application; however, you are going
to implement it slightly differently from how it is implemented here, so it is best to just
remove the entire statement for now.

iPhone developer Company provides mobile application development services that offers complete mobile computing solution for all needs.

Cheapest cell phone plans Consumer Cellular is a nationwide provider of best cell phone plans and cell phones for senior citizens, young and adults which are cheap, affordable and without any contracts.

Video Chat for Android in 30 Lines of Code

Posted by admin December - 6 - 2010 - Monday ADD COMMENTS
YouTube Preview Image

TIP Part 2

Posted by admin November - 22 - 2010 - Monday ADD COMMENTS

Considering that the setContentView( ) method is being told to set main.xml as the
current View, and main.xml contains a TextView that says “Hello World, HelloWorldText,”
it may be safe to assume that compiling and running HelloWorldText now will give
you your Hello World! application. To test this, run your unaltered HelloWorldText
application. Choose Run | Run to open the Run As dialog box, select Android Application,
and click OK.

The new project you just established contains the code to create a Hello World!
application on its own. However, that is not very engaging, nor does it teach you very
much about programming an Android application. You need to dissect the project and
see exactly how the project displayed the “Hello World!” message.
What happened when you created the new Android project is that the Android plugin
modified main.xml. This is a perfect example of one way to modify the UI in Android.
The following lines of code are added to main.xml by the Android SDK when the project
is created:
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”Hello World, HelloWorldText”
/>

TIP

Posted by admin November - 9 - 2010 - Tuesday ADD COMMENTS

If you do not see the android.os.Bundle import statement in your project, expand the
tree within your development window. Eclipse rolls up all the import statements under
the first one, so you must expand the tree to see the rest of them.
Focusing now on your class HelloWorldText, you can see that it extends the Activity
class. Activity is imported from the previous lines. All applications derive the Activity class,
and this derivation is required for running an application on Android. For something to
run and be displayed on the screen, it must be derived from Activity.
The HelloWorldText class holds the code needed to create, display, and run your
application. Right now there is only one method in your HelloWorldText class that is
defined with code in it, onCreate( ).
The onCreate( ) method takes in icicle as a bundle. That is, all of the current
state information is bundled as an icicle object and held in memory. You will not be
directly handling icicle in this application, but you need to be aware of its presence
and purpose.

The next line in the file is the one that really does some perceptible action:
setContentView(R.layout.main);
The method setContentView( ) sets the Activity’s content to the specified resource.
In this case, we are using the main.xml file from the layout directory via the pointer in
the R.java file. The main.xml file, right now, contains nothing more than the size of the
HelloWorldText screen and a TextView. The TextView is derived from View and is used
to display text in an Android environment. Reviewing the contents of main.xml, you can
see that it contains the following line:
android:text=”Hello World, HelloWorldText”

.java File

Posted by admin October - 29 - 2010 - Friday ADD COMMENTS

<activity>.java File The file in the src directory that you will spend the most time with
is <activity>.java (HelloWorldText.java in this example), which is created by the Android
plugin and named to match the Activity name that you specified in the New Android
Project wizard. Unlike most of the files you have examined in this section, this file is
completely editable; in fact, it will do very little for you if you do not modify it with
your code.
After briefly looking at what is in your HelloWorldText.java file as it is created by the
Android plugin, you will then edit the file to create your first Android Activity.

package android_programmers_guide.HelloWorldText;
import android.app.Activity;
import android.os.Bundle;

public class HelloWorldText extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
}
}
The three lines at the top of the file are the standard preprocessor directives—that is,
as in most programming languages, statements that are directives to the compiler to run
before the application process. In this case, you have the definition and inclusion of your
package android_programmers_guide.HelloWorldText.
The next two lines import specific packages from the Android SDK via android.jar:
import android.app.Activity;
and

import android.os.Bundle;
These lines tell the project to include all the code from the imported packages before all
the code in your application. These two lines are critical for your base Android application
and should not be removed..

R.java File

Posted by admin October - 14 - 2010 - Thursday ADD COMMENTS

R.java File The file R.java is an auto-generated file that is added to your application by the Android plugin. This file contains pointers into the drawable, layout, and values directories (or the items within the directories, as is the case with strings and icons). You should never have to modify this file directly. You will be referencing R.java in most of your applications. The code that was auto-generated for the HelloWorldText application follows:

/* 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 testPackage.HelloWorldText;
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=0x7f040000;
}
}

NOTE
The comment section of the R.java file provides an explanation of the origin of the file. It states that the file was created by the aapt tool. In Chapter 6, when you create a command-line–only version of the Hello World! application, you will use command-line tools to create all of the auto-generated files.

Directories in android

Posted by admin October - 4 - 2010 - Monday ADD COMMENTS

Directories

There are also three directories in the project root—res, assets, and src—each of which has a distinct purpose. These directories play an integral part in the operation of your application.

res Directory

The res directory is where your in project resources are held and compiled into your application. When you create a new Android project, the res directory contains three subdirectories: drawable, layout, and values. You will use the drawable and layout directories in many of your projects to hold and display images and layouts respectively, whereas the values directory holds string globals that can be used throughout your

application.

NOTE

A reference to the res directory and its contents is contained by the R.java file, located in the src directory. This file is covered in much more detail later in the chapter. The drawable directory contains actual image files that your application can use and reference. The layout directory holds an XML file, main.xml, that is referenced by your application when building its interface. In most of the applications in this book, you will

be editing the main.xml file included in the layout directory. This will allow you to insert Views into the application’s visual layout and display them. An unaltered main.xml file contains the following code:

<?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=”Hello World, HelloWorldText”

/>

</LinearLayout>

The last directory under res, values, holds an XML file named strings. The strings.xml file is used to hold global string values that can be referenced by your application.

assets Directory

The assets directory is used to hold raw asset files. The files contained in the assets directory can include audio files for streaming and animation assets. we will not use any audio assets in the applications for this book because the beta audio drivers for the Android Emulator are not yet optimized.

src Directory

The src directory contains all the source files for your project. When your project is first created, it will contain two files, R.java and <activity>.java (in this example,

HelloWorldText.java), described next.

NOTE

<activity>.java is always named according to your Activity name.

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.

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.