Amazon affiliate



Saturday, January 28, 2017

Hello world app in Android

To run the Hello World application, you need to install at least one Android platform in your SDK environment. If you have not already performed this step, you need to do it now.
To install a platform in Eclipse:
  • In the Android SDK and AVD Manager, choose Available Packages in the left panel.
  • In the right panel, expand the Android Repository list to display the components available for installation.
  • Select at least one platform to install, and click Install Selected. If you aren't sure which platform to install, use the latest version.

Create an AVD

In this tutorial, you will run your application in the Android Emulator. Before you can launch the emulator, you must create an Android Virtual Device (AVD). An AVD defines the system image and device settings used by the emulator.
To create an AVD:
  • In Eclipse, select Window > Android SDK and AVD Manager.
  • Select Virtual Devices in the left panel.
  • Click New.... The Create New AVD dialog appears.
  • Type the name of the AVD, such as "my_avd".
  • Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.3.3) you want to run on the emulator. For this tutorial, choose the latest platform that you have installed and ignore the rest of the fields.
  • Click Create AVD.

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.
  • 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". (After you create one or more Android projects, an entry for "Android XML File" will also be available.)
  • Select "Android Project" and click Next




Fill in the project details with the following values:
  • Project name: HelloAndroid
  • Build Target: Select a platform version that is equal to or lower than the target you chose for your AVD.
  • Application name: Hello, Android
  • Package name: com.example.helloandroid (or your own private namespace)
  • Create Activity: HelloAndroid
  • Click Finish.


    Here is a description of each field:
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 2.3.3. 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.
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. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

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;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
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.

Run the Application

The Eclipse plugin makes it easy to run your applications:
  • Select Run > Run.
  • 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 plugin installs your application and launches the default Activity. You should now see something like this:

-----------------------------------------------------------------------------

Wednesday, July 20, 2016

Top 20 Aptitude Interview Questions And Answers

Top 20 Aptitude  Interview Questions And Answers


We have already shared the most frequently asked java, hr and other interview questions for experience and fresher candidates. Also shared the tricky coding interview questions in our previous posts. Today , we will learn about the top 20 Aptitude interview questions and answers.



to read question And Answer click here..

-----------------------------------------------------------------------------

Tuesday, July 12, 2016

top-50-java interview question

Top 50 Java Collections Interview Questions And Answers

We have already shared the most frequently asked java ,jsp and hr interview questions for experience candidates. Also shared the tricky coding interview questions in our previous posts. Today , we will learn about the top 50 Android interview questions and answers.


to read question click here..

-----------------------------------------------------------------------------

Top 20 JSP Interview Questions And Answers

Top 20 JSP  Interview Questions And Answers

We have already shared the most frequently asked java and hr interview questions for experience and fresher candidates. Also shared the tricky coding interview questions in our previous posts. Today , we will learn about the top 20 JSP interview questions and answers.


to read question And Answer click here..

-----------------------------------------------------------------------------

Sunday, July 10, 2016

Top 50 Java Collections Interview Questions And Answers

Top 50 Java Collections Interview Questions And Answers

We have already shared the most frequently asked java interview questions for experience candidates. Also shared the tricky coding interview questions in our previous posts. Today , we will learn about the top 50 java collections interview questions and answers. We will divide this post into three categories :

Beginner level (0-1 year experience (Freshers)) ,

Intermediate level (1-3 years experienced Java Developers)

Advanced level(3+ Experienced) java collections interview questions and answers

Note : Please prepare all the below questions . Interviewer may choose to ask any question. 
to read question click here..

-----------------------------------------------------------------------------

Friday, July 8, 2016

50 Common Interview Questions and Answers for HR interview

50 Common Interview Questions and Answers for HR interview


What kind of salary do you need? Are you applying for other jobs? Why should we hire you? Review these typical interview, questions and think about how you would answer them, Read the questions listed; you’ll also find some strategy suggestions with it. to view question click here

-----------------------------------------------------------------------------