tag:blogger.com,1999:blog-61580395034776456992024-02-27T00:09:39.741-07:00Android Code MonkeyAndroid Development Tutorials and Code ExamplesAnonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-6158039503477645699.post-91274965431033408932011-10-25T22:32:00.001-06:002011-10-25T22:36:39.095-06:00How to solve Must Override a Superclass Method Error<b>Ever import some Android sample code into eclipse and get the dreaded "Must Override a Superclass Method Error"? </b><br />
In this blog post I am going to explain the source of the problem and how to fix it.<br />
<br />
<b>You might receive an error like this:</b><br />
<i>The method onClick(View) of type new View.OnClickListener(){} must override a superclass method Java Problem</i><br />
<br />
<div><b><br />
</b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgviNeBuV_tRdaZ9aIkgjanWN08nYnBGmcLUUfo5DGOnpzKV_0ZJUoFB288wX1RsWG6PcrjtCtx6Pr1wEKMtFcDbxBJA2FepzsL0vs_N6ue2It5D0Lcejisz4FtZJlCIqYnb2U9mbcZxnhT/s1600/o1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgviNeBuV_tRdaZ9aIkgjanWN08nYnBGmcLUUfo5DGOnpzKV_0ZJUoFB288wX1RsWG6PcrjtCtx6Pr1wEKMtFcDbxBJA2FepzsL0vs_N6ue2It5D0Lcejisz4FtZJlCIqYnb2U9mbcZxnhT/s320/o1.PNG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii7-niSF23BEq0Vc9SgwjdNdQDwJL2RkHZ3kqD5jT1PN3iiWnc0-eZNF5S71UtvbGx04AAsVJu08rtSx-jGbNAaCVTjXPH9KUhl7xafm2Rdkud0k6xoTlJtrBw8mYaL1iGdMaWCaY4QiSi/s1600/o2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="49" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii7-niSF23BEq0Vc9SgwjdNdQDwJL2RkHZ3kqD5jT1PN3iiWnc0-eZNF5S71UtvbGx04AAsVJu08rtSx-jGbNAaCVTjXPH9KUhl7xafm2Rdkud0k6xoTlJtrBw8mYaL1iGdMaWCaY4QiSi/s640/o2.PNG" width="640" /></a></div><b><br />
</b><br />
<b>The Source of the Problem: </b>The project was written with a Java JDK Compiler compliance level of 1.6 but your eclipse setting is 1.5.<br />
<br />
<b>How to fix the problem: </b><br />
<br />
<br />
Right click on your project and select "properties"</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFHNnbYE-E9YgC4o-Cvs1JFWK-_FUwV3dgeWvLxfMTz2Y0VlQvvi7H-8fOxPZQCja23HX9IZtKLDlL51SQ2Tv4XLn1H108qwGyhw7QpJ_O5Qye5W4VJUawH9MAJXEGoLgell8FuN1KvQju/s1600/o3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFHNnbYE-E9YgC4o-Cvs1JFWK-_FUwV3dgeWvLxfMTz2Y0VlQvvi7H-8fOxPZQCja23HX9IZtKLDlL51SQ2Tv4XLn1H108qwGyhw7QpJ_O5Qye5W4VJUawH9MAJXEGoLgell8FuN1KvQju/s320/o3.PNG" width="207" /></a></div><div>Select "Java Compiler" </div><div>Make sure "Enable project specific settings" is checked</div><div>Change the "Compiler compliance level:" to 1.6</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoCq2phCgYOLog5HQj90PvvOBUVUWghWQCLRpdkJ266dBfQmUZHQStYYB6maBSWGKmC7KEdgysMDhS7pz9-CQnYpfiPg6C0v9HDmJK6TPbUG7O1QxEgy5IwcDo4WC_OInjCNX4iR-TZaOy/s1600/o4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="303" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoCq2phCgYOLog5HQj90PvvOBUVUWghWQCLRpdkJ266dBfQmUZHQStYYB6maBSWGKmC7KEdgysMDhS7pz9-CQnYpfiPg6C0v9HDmJK6TPbUG7O1QxEgy5IwcDo4WC_OInjCNX4iR-TZaOy/s320/o4.PNG" width="320" /></a></div><div>Save the changes. </div><div>Now select "Project" > "Clean..." </div><div>Your project should now build without any errors.</div><div><br />
</div>Please feel free to post comments or questions. I usually post a reply within a day or two.<b><br />
</b>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com62tag:blogger.com,1999:blog-6158039503477645699.post-40607526298585038292011-10-18T22:56:00.000-06:002011-10-18T22:56:29.023-06:00Android Garage Door App<h3>Ever wanted to check your garage door from you Android phone? <br />
Now You can Open and Close Your Garage Door with Your Phone.</h3><br />
This "How To" guide is a complete tutorial, taking you through the entire process step by step. I have included a working Android app you can use "as-is" or use it as a starting point and improve it. At the end of the tutorial, I will document some things I would recommend be added to the app.<br />
<br />
Let's get started. Open eclipse and start a new project. If you need help setting up your development environment, I have created a detailed step by step guide. Here is a link.<br />
<br />
<a href="http://androidcodemonkey.blogspot.com/2010/01/how-to-setup-android-development_23.html">How to Setup Android Development Environment</a><br />
<br />
<span class="Apple-style-span" style="font-size: large;"><b>Create a new project</b></span><br />
Project name: <b>Garage Door App</b><br />
Build target: I targeted <b>Android 2.3.1</b> but I believe the code would run as low as 1.6. So if you phone is not lower than v2.3.1 select the appropriate API<br />
Application name: <b>Garage Door App</b><br />
Package name: <b>com.acm.blog.example.garagedoorapp</b><br />
Check "Create activity:" and name it "<b>MainActivity</b>"<br />
Min SDK version: <b>9</b> (again if you target a lower API adjust this number to the appropriate API level)<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw6gkKCZgy_F8inTJWy_bSMJkl_Km0anVLhITmfwMoh3rcdYPob3kxmsrZjQTCc1J7-dHkWfEWb9YRB5slVurmHs2G8ZJigSDExa1wEoCfw7vpl_gYRhot1EFXYuzj-yVLDY4HeANNPfNG/s1600/New+Project.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw6gkKCZgy_F8inTJWy_bSMJkl_Km0anVLhITmfwMoh3rcdYPob3kxmsrZjQTCc1J7-dHkWfEWb9YRB5slVurmHs2G8ZJigSDExa1wEoCfw7vpl_gYRhot1EFXYuzj-yVLDY4HeANNPfNG/s320/New+Project.PNG" width="174" /></a></div><br />
<br />
Here is what our app is going to look like when done.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCdWLTZH5dpv5lqIrD7LZG78Qg2uh1-ZDQS3nY_Cy5YMGdFlWrCTvChux7Ub4jQnqYL0jDjDKdun3pmml-c2b2CQIXCTShnDa_Wjs17QRedzMwCxItoOvOSOh043Z_Xsw0AF0j3QQ-nCmP/s1600/garage+door+app.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCdWLTZH5dpv5lqIrD7LZG78Qg2uh1-ZDQS3nY_Cy5YMGdFlWrCTvChux7Ub4jQnqYL0jDjDKdun3pmml-c2b2CQIXCTShnDa_Wjs17QRedzMwCxItoOvOSOh043Z_Xsw0AF0j3QQ-nCmP/s320/garage+door+app.png" width="192" /></a></div><br />
It is made up of three controls.<br />
<br />
<ol><li>An open garage door button.</li>
<li>A close garage door button.</li>
<li>And finally a status display which will let us know when the door is open or closed. I also coded it so when you touch the display graphic the app will check the door and update the status.</li>
</ol><div><span class="Apple-style-span" style="font-size: large;"><b>Let's start coding!</b></span></div><div><b>Step 1: </b>Create the layout by editing the <b>main.xml</b> file already created for us. If you new to Android the layout might be a little confusing. Here is a complete explanation of the layout file.<br />
<table cellpadding="2" cellspacing="2" style="height: 250px; text-align: left; width: 800px;"><tbody>
<tr> <td style="width: 350px;" valign="top"><br />
<ul><li>Starting on <b>line 1 </b>and ending on <b>line 19</b> is a "Linear Layout" that encompasses the entire layout. We specify that the orientation is vertical. As new controls get added they appear at the bottom. We also set the background to our brushed aluminum graphic.</li>
<li><b>Lines 2-4</b> are a Linear layout with a TextView for "Garage Door Opener". I wrapped the TextView in a linear layout so I could center it with android:gravity="center_horizontal"</li>
<li>I used a frame layout on <b>lines 5-12</b> so that I can layer controls on top of each other. I wanted the progress bar to be dead center of our status graphic.</li>
<li><b>Lines 6-8</b> is our status graphic that is centered with the property android:gravity="center_horizontal"</li>
<li><b>Lines 9-11</b> is the progress bar that we display while making our web service calls in a background thread. Also centered.</li>
<li><b>Lines 13-18</b> is a linear layout (outside of the frame so it appears below it). This linear layout is set to stack the controls horizontally with the following property android:orientation="horizontal". We have two image buttons in this layout.</li>
</ul><div><br />
</div></td> <td style="width: 450px;" valign="top"><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgghZs3orycJt8V6-60nL-Y5dH5Y7Y3QlijDPBO6pjSJT_26WW8uvdXvlBbRjiTdpYIefFv9OUm4Xwk-MBIS3n68DRRqdNhGhUj_P6f9G0ZCqa2a7AxPG5ZWPjHokoU7inS8hUTMPn7cVbv/s1600/garage-door-layout-xml-explained.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgghZs3orycJt8V6-60nL-Y5dH5Y7Y3QlijDPBO6pjSJT_26WW8uvdXvlBbRjiTdpYIefFv9OUm4Xwk-MBIS3n68DRRqdNhGhUj_P6f9G0ZCqa2a7AxPG5ZWPjHokoU7inS8hUTMPn7cVbv/s320/garage-door-layout-xml-explained.png" width="288" /></a></div></td> </tr>
</tbody></table><br />
<div><br />
<b><span class="Apple-style-span" style="font-family: inherit;">Main.xml</span></b><br />
<pre class="brush: xml; highlight: [1] "><linearlayout android:background="@drawable/background" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<linearlayout android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
<textview android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingtop="4dip" android:text="Garage Door Opener" android:textcolor="#cc6600" android:textsize="20dip"></textview>
</linearlayout>
<framelayout android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal" android:paddingtop="35dip">
<linearlayout android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal" android:paddingtop="35dip">
<imageview android:gravity="center_horizontal" android:id="@+id/Status_ImageView" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/status_unknown"></imageview>
</linearlayout>
<linearlayout android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal" android:paddingtop="80dip">
<progressbar android:id="@+id/progressBar1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="invisible"></progressbar>
</linearlayout>
</framelayout>
<linearlayout android:gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal" android:paddingtop="80dip">
<imagebutton android:background="#00000000" android:contentdescription="info" android:id="@+id/OpenButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingright="10dip" android:src="@drawable/open_button" android:tag="dooclosed">
</imagebutton>
<imagebutton android:background="#00000000" android:contentdescription="info" android:id="@+id/CloseButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:paddingright="10dip" android:src="@drawable/close_button">
</imagebutton>
</linearlayout>
</linearlayout>
</pre><br />
<br />
<b>Step 2:</b> Before we code our main activity let's create a helper class to make the http calls to the Netduino.</div><div><ul><li>Right click on the project name and select New > Class</li>
<li>Name it "WebService.java". Now lets go through the code.</li>
<li>Line 2 we will make a constant string containing the Netduino IP address</li>
</ul></div><pre class="brush: java; highlight: [2]">public class WebService {
private final String WEBSERVICE_URL = "http://192.168.0.153/";
...
...
</pre><ul><li>Line 3 declare an HttpClient we will use to make the HTTP cals</li>
</ul><pre class="brush: java; highlight: [3]">public class WebService {
private final String WEBSERVICE_URL = "http://192.168.0.153/";
private HttpClient client;
...
</pre><ul><li>Create a constructor and in it instantiate our HttpClient</li>
</ul><pre class="brush: java; highlight: [3,4,5]; first-line: 2;">...
public WebService(){
client = new DefaultHttpClient();
}
...
</pre><ul><li>Create a private method that calls the webservice and parses the retun</li>
</ul><pre class="brush: java; highlight: [24, 25,26,27,28,29,30,31,32,33,34,35,36,37,38]; first-line: 24;">private String MakeHTTPCall(String method){
HttpGet get = new HttpGet(WEBSERVICE_URL + method);
try {
// Create a response handler
ResponseHandler<string> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(get, responseHandler);
return responseBody;
} catch (IOException e) { // -|
e.printStackTrace(); // |--> Oops something went wrong!
} catch (Exception e) { // |
e.printStackTrace(); // -|
}
return "failed"; //Return "failed" if we encounter an error
}
</string></pre><ul><li>Create a new HTTP get passing in the web service URL and the method name</li>
</ul><pre class="brush: java; highlight: [25]; first-line: 24;">private String MakeHTTPCall(String method){
HttpGet get = new HttpGet(WEBSERVICE_URL + method);
try {
// Create a response handler
ResponseHandler<string> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(get, responseHandler);
return responseBody;
} catch (IOException e) { // -|
e.printStackTrace(); // |--> Oops something went wrong!
} catch (Exception e) { // |
e.printStackTrace(); // -|
}
return "failed"; //Return "failed" if we encounter an error
}
</string></pre><ul><li>Instantiate a new BasicResponseHandler to parse our webservice return into a string</li>
<li>Create a String variable to hold the return and call execute on the HttpClient</li>
<li>We pass in the HttpGet variable and the response handler</li>
</ul><pre class="brush: java; highlight: [28,29]; first-line: 24;">private String MakeHTTPCall(String method){
HttpGet get = new HttpGet(WEBSERVICE_URL + method);
try {
// Create a response handler
ResponseHandler<string> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(get, responseHandler);
return responseBody;
} catch (IOException e) { // -|
e.printStackTrace(); // |--> Oops something went wrong!
} catch (Exception e) { // |
e.printStackTrace(); // -|
}
return "failed"; //Return "failed" if we encounter an error
}
</string></pre><ul><li>Return the result from the HTTP GET call. We wrap the HTTP call in try catch.</li>
</ul><pre class="brush: java; highlight: [30]; first-line: 24;">private String MakeHTTPCall(String method){
HttpGet get = new HttpGet(WEBSERVICE_URL + method);
try {
// Create a response handler
ResponseHandler<string> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(get, responseHandler);
return responseBody;
} catch (IOException e) { // -|
e.printStackTrace(); // |--> Oops something went wrong!
} catch (Exception e) { // |
e.printStackTrace(); // -|
}
return "failed"; //Return "failed" if we encounter an error
}
</string></pre><br />
<br />
<br />
<br />
<br />
<br />
<div><b>WebService.java</b></div></div><div><pre class="brush: java;">public class WebService {
private final String WEBSERVICE_URL = "http://192.168.0.153/";
private HttpClient client;
public WebService(){
client = new DefaultHttpClient();
}
public String IsGarageDoorOpen(){
for(int i = 0; i < 5; i++){
String s = MakeHTTPCall("checkdoor");
if(s.equals("failed") == false)
return s; //Got a response return result
}
return "failed"; //Oh well we tried 5 times without success
}
public String ActivateGarageDoor(){
for(int i=0; i < 5; i++){
String s = MakeHTTPCall("activatedoor");
if(s.equals("failed") == false)
return s; //Got a response return result
}
return "failed";
}
private String MakeHTTPCall(String method){
HttpGet get = new HttpGet(WEBSERVICE_URL + method);
try {
// Create a response handler
ResponseHandler<string> responseHandler = new BasicResponseHandler();
String responseBody = client.execute(get, responseHandler);
return responseBody;
} catch (IOException e) { // -|
e.printStackTrace(); // |--> Oops something went wrong!
} catch (Exception e) { // |
e.printStackTrace(); // -|
}
return "failed"; //Return "failed" if we encounter an error
}
}
</string></pre><br />
<br />
<div><b>Step 3:</b> Let's edit our Main Activity.</div></div><div><ul><li>Line 2 is our progress bar we will display while we check the status of the garage door in a background thread. It is always a good idea to let the user know when the app is working in the background.</li>
<li>Line 3 is an instance of our ImageView we will use to display the status of the garage door.</li>
<li>Line 4 is an instance of our web service helper class. </li>
</ul><div></div><pre class="brush: java; highlight: [2,3,4]">public class MainActivity extends Activity {
private ProgressBar progressBar1;
private ImageView status;
private WebService ws;
</pre></div><div><div>Now let's add some code to the onCreate method<br />
<br />
<ul><li>On line 9 we turn of the window title bar. </li>
<li>Line 12 instantiate the progress bar.</li>
<li>Line 13 the ImageView we are using to display the status of the garage door.</li>
<li>Lines 14-19 set the on click listener so we can check the status of the garage door when someone touches the status image. We someone clicks the ImageView we execute an AsyncTask to check the garage door in a background thread.</li>
<li>Line 20 instantiate our Open ImageButton.</li>
<li>Lines 21-26 set the on click listener for the open button. When the open button is clicked we activate the garage door with an AsyncTask on a background thread.</li>
<li>Lines 27-33 is the same for the Close button.</li>
<li>Lines 34-48 We create a Timer to check the status of the garage door every fifteen minutes again on a background thread.</li>
</ul></div><pre class="brush: java; first-line: 6;">@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
ws = new WebService();
progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
status = (ImageView) findViewById(R.id.Status_ImageView);
status.setOnClickListener(new OnClickListener() {
public void onClick(View v) { // Check garage door
new CheckGarageDoorAsync().execute(); // when status
// image clicked
}
});
ImageButton openButton = (ImageButton) findViewById(R.id.OpenButton);
openButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
new ActivateGarageDoorAsync().execute();
}
});
ImageButton closeButton = (ImageButton) findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
new ActivateGarageDoorAsync().execute();
}
});
final Handler handler = new Handler();
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
Log.d("z", "check garage door");
setUI(ws.IsGarageDoorOpen());
}
});
}
}, 0, 900000);
new CheckGarageDoorAsync().execute();
}
}
</pre></div><br />
Lines 56-92 is a method that sets our UI depending on the state of the garage door. If the garage door is open we disable the open button and set the display to "Open" and of course the opposite if its closed.<br />
<br />
<pre class="brush: java; first-line: 56;">private void setUI(String mode) {
if (mode.equals("Open")) {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button_alt); // Open button
// depressed
o.setEnabled(false); // Disable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button); // Closed button up
c.setEnabled(true); // Enable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_open); // Set status
// graphic
} else if (mode.equals("Closed")) {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button); // Open button up
o.setEnabled(true); // Enable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button_alt); // Close button
// depressed
c.setEnabled(false); // Disable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_closed);// Set status
// graphic
} else {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button_alt); // Open button
// depressed
o.setEnabled(false); // Disable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button_alt); // Close button
// depressed
c.setEnabled(false); // Disable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_unknown);// Set status
// graphic
}
}
</pre><br />
Lines 97-117 We create an AsyncTask to check the status of the garage door. Using an AsyncTask allows us the make an http call on a background thread so our app does not become un-responsive and geneate an "ANR" error. If you perform a long task on the UI thread and the user presses a key and there is no response within 5 seconds Android will generate an ANR error message asking the user to wait or to close. You should never perform a network call on the UI thread. We implement three methods of the AsyncTask.<br />
<br />
<ol><li>onPreExecute(). This is performed on the UI thread. We turn on the progress bar indicating we are checking the door.</li>
<li>doInBackground(). This is performed in a background thread. In this method we check the garage door state by calling our IsGarageOpen method on our web service class. We then pass the results to onPostExecute() method.</li>
<li>onPostExecute(). This is performed on the UI thread. This method sets all the controls based on the state of the garage door.</li>
</ol><br />
<pre class="brush: java; first-line: 97;">private class CheckGarageDoorAsync extends AsyncTask<void, string[]="" void,=""> {
@Override
protected void onPreExecute() {
setUI("Unkown"); // While we check disable all buttons and clear status display
progressBar1.setVisibility(View.VISIBLE); // Display progress bar
}
@Override
protected String[] doInBackground(Void... arg0) {
String r = ws.IsGarageDoorOpen(); // Make webservice call to check
// garage door
return new String[] { r }; // Return result
}
@Override
protected void onPostExecute(String[] result) {
progressBar1.setVisibility(View.INVISIBLE); // Hide progress bar
setUI(result[0]); // Pass result to setUI method to sync the UI
}
}
</void,></pre><br />
Lines 122-161 We create another AsyncTask to activate the garage door. Here is the complete MainActivity class.<br />
<b>MainActivity.java</b><br />
<div><pre class="brush: java;">public class MainActivity extends Activity {
private ProgressBar progressBar1;
private ImageView status;
private WebService ws;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
ws = new WebService();
progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
status = (ImageView) findViewById(R.id.Status_ImageView);
status.setOnClickListener(new OnClickListener() {
public void onClick(View v) { // Check garage door
new CheckGarageDoorAsync().execute(); // when status
// image clicked
}
});
ImageButton openButton = (ImageButton) findViewById(R.id.OpenButton);
openButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
new ActivateGarageDoorAsync().execute();
}
});
ImageButton closeButton = (ImageButton) findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
new ActivateGarageDoorAsync().execute();
}
});
final Handler handler = new Handler();
Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
Log.d("z", "check garage door");
setUI(ws.IsGarageDoorOpen());
}
});
}
}, 0, 900000);
new CheckGarageDoorAsync().execute();
}
/*
* Set UI components Garage Open Open button is disabled Close button is
* enabled Status graphic - OPEN Garage Closed Open button is enabled Close
* button is disabled Status graphic - Closed Garage Unknown Open button is
* disabled Close button is disabled Status graphic - black
*/
private void setUI(String mode) {
if (mode.equals("Open")) {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button_alt); // Open button
// depressed
o.setEnabled(false); // Disable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button); // Closed button up
c.setEnabled(true); // Enable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_open); // Set status
// graphic
} else if (mode.equals("Closed")) {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button); // Open button up
o.setEnabled(true); // Enable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button_alt); // Close button
// depressed
c.setEnabled(false); // Disable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_closed);// Set status
// graphic
} else {
ImageButton o = (ImageButton) findViewById(R.id.OpenButton);
o.setImageResource(R.drawable.open_button_alt); // Open button
// depressed
o.setEnabled(false); // Disable open button
ImageButton c = (ImageButton) findViewById(R.id.CloseButton);
c.setImageResource(R.drawable.close_button_alt); // Close button
// depressed
c.setEnabled(false); // Disable close button
ImageView status = (ImageView) findViewById(R.id.Status_ImageView);
status.setImageResource(R.drawable.status_unknown);// Set status
// graphic
}
}
/*
* Check the garage door on background thread with an AsyncTask
*/
private class CheckGarageDoorAsync extends AsyncTask<void, string[]="" void,=""> {
@Override
protected void onPreExecute() {
setUI("Unkown"); // While we check disable all buttons and clear status display
progressBar1.setVisibility(View.VISIBLE); // Display progress bar
}
@Override
protected String[] doInBackground(Void... arg0) {
String r = ws.IsGarageDoorOpen(); // Make webservice call to check
// garage door
return new String[] { r }; // Return result
}
@Override
protected void onPostExecute(String[] result) {
progressBar1.setVisibility(View.INVISIBLE); // Hide progress bar
setUI(result[0]); // Pass result to setUI method to sync the UI
}
}
/*
* Activate the garage door on a background thread with an AsyncTask
*/
private class ActivateGarageDoorAsync extends
AsyncTask<string, string,="" string[]=""> {
@Override
protected void onPreExecute() {
setUI("Unkown"); // While we check disable all buttons and clear
// display graphic
progressBar1.setVisibility(View.VISIBLE); // Display progress bar
}
@Override
protected String[] doInBackground(String... arg0) {
String start = ws.IsGarageDoorOpen();
String r = ws.ActivateGarageDoor(); // Activate garage door
for (int i = 0; i < 60; i++) { // Give the door up to 1 minute to
// close/open
try {
Thread.sleep(1000); // Pause for 1 second
} catch (InterruptedException e) {
e.printStackTrace();
}
r = ws.IsGarageDoorOpen(); // Check the door status
if (r.equals(start) == false && r.equals("failed") == false)
break; // The door is done opening/closing
}
return new String[] { r }; // Return the status of garage
}
@Override
protected void onProgressUpdate(String... values) {
}
@Override
protected void onPostExecute(String[] result) {
progressBar1.setVisibility(View.INVISIBLE);
setUI(result[0]);
}
}
}
</string,></void,></pre></div><br />
You can get the entire project source code here<br />
<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="https://skydrive.live.com/embedicon.aspx/Blog%20Files/GarageDoorApp.zip?cid=369caadcbdc49509&sc=documents" style="background-color: #fcfcfc; height: 115px; padding: 0; width: 98px;" title="Preview"></iframe><br />
<br />
To learn how to build the hardware required to monitor and control your garage door read my post here. <a href="http://androidcodemonkey.blogspot.com/2011/09/mobile-app-to-monitor-open-and-close.html">http://androidcodemonkey.blogspot.com/2011/09/mobile-app-to-monitor-open-and-close.html</a>. If you have any questions please feel free to leave a comment. I usually answer questions within a day or two.Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com44tag:blogger.com,1999:blog-6158039503477645699.post-33003809346094107082011-09-14T21:07:00.006-06:002011-10-18T23:07:23.984-06:00Android app to monitor & open and close garage doorHave you ever wanted to know if your garage door is open without having to go and check it? There have been many blog posts to light an LED when you leave your garage door open, but I want something more convenient. I decided to write an Android app that would allow me to monitor my garage door and even open or close from anywhere. I am going to provide complete instructions for building the required hardware and the android app code.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigGJi00-ZycKPdGKur7LMxkmfrPJRhp1XeAldhfDY8COlicGxogoKkqBJZz3WVvt15xGn6DQLvjpWIbQxFGLozaIdsJGkRi-zp6PVm3ptCU2zYL2B0tAK9aOTm3nVGuCkjAgxrJt9c2Mlx/s1600/HomeAutomation.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigGJi00-ZycKPdGKur7LMxkmfrPJRhp1XeAldhfDY8COlicGxogoKkqBJZz3WVvt15xGn6DQLvjpWIbQxFGLozaIdsJGkRi-zp6PVm3ptCU2zYL2B0tAK9aOTm3nVGuCkjAgxrJt9c2Mlx/s320/HomeAutomation.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Monitor your garage door with an Android app</td></tr>
</tbody></table>What is required? We need to build the following:<br />
<ul><li>Using a Netduino board (or an Arduino board with an Ethernet shield) build a sensor to detect if the garage door is open or closed. I chose an infrared phototransistor so I would not have to make physical contact with the door and because it's cheap! Like $1.13 cheap!<br />
<b><a href="http://netduinohacking.blogspot.com/2011/09/garage-door-monitor-with-netduino-and.html">Build and program a garage door sensor</a></b></li>
<li>To open or close the garage door I wired an Optoisolator to a spare garage door opener.<br />
<a href="http://netduinohacking.blogspot.com/2011/09/open-close-garage-door-with-your.html"><b>Build and program a garage door opener</b></a><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBr9DAPieO01f5_Yza9M12yRewKMnSnX-HgNX00e5_QxpBbGOJmvd8zQZVUaFFdzcU_pwxj8jfQBqqA-GllipI-uz9txk28wKbRl0cuEnqkMnQAq8g29HGHeCN8WlIttpmzBVoSqBz4uu/s1600/GarageDoor-Opener-with-Optoisolator.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="162" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBr9DAPieO01f5_Yza9M12yRewKMnSnX-HgNX00e5_QxpBbGOJmvd8zQZVUaFFdzcU_pwxj8jfQBqqA-GllipI-uz9txk28wKbRl0cuEnqkMnQAq8g29HGHeCN8WlIttpmzBVoSqBz4uu/s320/GarageDoor-Opener-with-Optoisolator.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Open and close garage door with your Netduino</td></tr>
</tbody></table></li>
<li>Write a program (or you might hear it referred to as a sketch) to check the sensor and determine if the door is open or close and report it back over HTTP</li>
<li>Even though it's not required, I wrote a second RESTful webservice to talk to the Netduino web server (see diagram). That way the Netduino webserver is never exposed outside my private network. I have another computer with the RESTful webservice that has a layer of authentication that is exposed to the internet.</li>
<li>And finally an Android app that will display if the garage door is open or closed as well as open or close it. <a href="http://androidcodemonkey.blogspot.com/2011/10/android-garage-door-app.html"><b>Here are step by step instructions (with complete source code) for writing the Android App</b></a>.</li>
</ul>I will be covering each step with a detailed post.Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com28tag:blogger.com,1999:blog-6158039503477645699.post-79313690009841577772011-07-02T21:43:00.005-06:002011-07-03T08:45:16.051-06:00Store and Get an Object in Android Shared Preferences<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div>Can I store and retrieve an object in Android Shared Preferences? Yes! This tutorial will walk you through a complete tutorial. Source code included! There are times when you need to store a lightweight object in Shared Preferences. I stress lightweight. We are going to use Google's JSON library to do the object serialization/de-serialization.<br />
<ul><li>Let's create a new project.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNELnymB2IgcosPwJB-SX3MAJLqTgeFzF_myPbwT1ZQ2JpA6De_20Kh68jfV0C4iZdM5ZebL-X5Qgs6Tcjd63ptgU-9XnFWk1I_2_XD3SQXy46DIuMjLmU1eXZRHdsWsa-mJ0aMxBDspOO/s1600/create.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNELnymB2IgcosPwJB-SX3MAJLqTgeFzF_myPbwT1ZQ2JpA6De_20Kh68jfV0C4iZdM5ZebL-X5Qgs6Tcjd63ptgU-9XnFWk1I_2_XD3SQXy46DIuMjLmU1eXZRHdsWsa-mJ0aMxBDspOO/s320/create.PNG" width="155" /></a></div>Download the latest gson jar from <a href="http://code.google.com/p/google-gson/downloads/list">http://code.google.com/p/google-gson/downloads/list</a>. I am using version 1.7. Place the jar somewhere convenient (If I intend to use the jar in several projects, I will place in a folder outside of my project). For this example, I will create a new folder called "lib" inside the project folder. Place the jar you downloaded in "lib" folder. Now we need to add a reference to gson jar.<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"></div><ul><li>Open the project properties. Right click on project name "ObjectsInSharedPreferenceSample" or whatever you called your project and select "Properties"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0olVt6vQhM9Dj9P9v3qX4SUKIJHRG4pz48V8GJFKJpEu-AryJaN5UaRBEM3cTPYHW_T03t6kj0FFkAtH-Qzcz4EtQRpP1oV8X95OCz8amiORUkT7xMeU7qmbJiNf6N9YA_5NPpZigfGlB/s1600/sharedpreferences1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0olVt6vQhM9Dj9P9v3qX4SUKIJHRG4pz48V8GJFKJpEu-AryJaN5UaRBEM3cTPYHW_T03t6kj0FFkAtH-Qzcz4EtQRpP1oV8X95OCz8amiORUkT7xMeU7qmbJiNf6N9YA_5NPpZigfGlB/s320/sharedpreferences1.PNG" width="212" /></a></div><ul><li>Select "Java Build Path" > "Add External JARS..."</li>
</ul><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP2KSfXVvF0vWFhdDgp3xu5otVG03QWI8RlqbMUQT9WrquAarLhZN9v1RcEZJkHFv2kli6Sug6rInO50F2dRGMIuBE1VSyGJ3PuQGDJ2xYRKQWclPVoJxtoGiV8pU_Inzj4w9YG9Lyl0DG/s1600/sharedpreferences2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP2KSfXVvF0vWFhdDgp3xu5otVG03QWI8RlqbMUQT9WrquAarLhZN9v1RcEZJkHFv2kli6Sug6rInO50F2dRGMIuBE1VSyGJ3PuQGDJ2xYRKQWclPVoJxtoGiV8pU_Inzj4w9YG9Lyl0DG/s320/sharedpreferences2.PNG" width="320" /></a></div><br />
<ul><li>Let's add a custom class that we are going to store and retrieve in the Shared Preferences. Add a new class "MyObject"</li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4b2ZSkStQMd57uUgOB4FbcwKc49iWCLjlVqy9E11OFE20z4QvNC2BnbWAQgSYTq52Q2qp2uGZSl7_uF1THjs6y1_6pf5dX9rn3bsmyOzydil06EcVMpJqVAdNnplK76rI5PfLel7YK88F/s1600/sharedpreferences3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4b2ZSkStQMd57uUgOB4FbcwKc49iWCLjlVqy9E11OFE20z4QvNC2BnbWAQgSYTq52Q2qp2uGZSl7_uF1THjs6y1_6pf5dX9rn3bsmyOzydil06EcVMpJqVAdNnplK76rI5PfLel7YK88F/s320/sharedpreferences3.PNG" width="268" /></a></div><br />
<ul><li>To keep the example simple, lets add just two public properties to our "MyObject" class</li>
<ul><li>public int myValue;</li>
<li>public String MyLabel;</li>
</ul><li>Add two buttons and two EditText. Make sure to add the onClick directive the XML so when the button is pressed our methods are executed.</li>
</ul><pre class="brush: xml; "><linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<button android:id="@+id/storeButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:onclick="storeButton_Clicked" android:text="Store"></button>
<edittext android:hint="Enter string" android:id="@+id/inputEditText" android:layout_height="wrap_content" android:layout_width="match_parent" android:text=""></edittext>
<button android:id="@+id/getButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:onclick="getButton_Clicked" android:text="Get"></button>
<edittext android:hint="" android:id="@+id/outputEditText" android:layout_height="wrap_content" android:layout_width="match_parent" android:text=""></edittext>
<div></div></linearlayout></pre></div><br />
<ul><li>Let's write some code. In the MainActivity add the following method. This method will be called when the store button is pressed. It will create an instance of "MyObject" and set the "MyValue" string to what ever you type in the EditText inputEditText. Then it will convert the object to a string using the gson library and store that string in the SharedPreferences.</li>
</ul><pre class="brush: java; ">public void storeButton_Clicked(View v){
EditText inputEditText = (EditText) findViewById(R.id.inputEditText);
MyObject obj = new MyObject();
obj.myValue = 2;
obj.MyLabel = inputEditText.getText().toString();
SharedPreferences appSharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
Editor prefsEditor = appSharedPrefs.edit();
Gson gson = new Gson();
String json = gson.toJson(obj);
prefsEditor.putString("MyObject", json);
prefsEditor.commit();
Toast.makeText(this, "Object stored in SharedPreferences", Toast.LENGTH_LONG);
}
</pre><div><br />
<ul><li>Now let's get the object from shared preferences and display it's properties in the outputEditText. </li>
</ul><div><pre class="brush: java; ">public void getButton_Clicked(View v){
EditText outputEditText = (EditText) findViewById(R.id.outputEditText);
SharedPreferences appSharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
Gson gson = new Gson();
String json = appSharedPrefs.getString("MyObject", "");
MyObject obj = gson.fromJson(json, MyObject.class);
outputEditText.setText("obj.MyLabel: [" + obj.MyLabel + "] obj.MyValue: [" + obj.myValue + "]");
}
</pre></div></div><div><br />
Run the program. Save an object and retrieve it from SharedPreferences. To keep things as simple as possible I only included required code. There is a lot of code missing that you will want to add like error checking and running off the UI thread. But this will get you started.<br />
<br />
Following is the complete source code for your review.</div><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="https://skydrive.live.com/embedicon.aspx/Blog%20Files/ObjectsInSharedPreferenceSample.zip?cid=369caadcbdc49509&sc=documents" style="background-color: #fcfcfc; height: 115px; padding: 0; width: 98px;" title="Preview"></iframe>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com22tag:blogger.com,1999:blog-6158039503477645699.post-69826192475715670652011-04-23T16:20:00.000-06:002011-04-23T16:20:36.283-06:00Eclipse Dark Color ThemeI discovered <a href="http://www.eclipsecolorthemes.org/?view=theme&id=1413">http://www.eclipsecolorthemes.org</a> for conveniently creating your own personal color scheme for eclipse. I am making available the dark theme I have been using for some time. Try it out or create your own easily on <a href="http://www.eclipsecolorthemes.org/?view=theme&id=1413">http://www.eclipsecolorthemes.org</a>.<br />
<a href="http://www.blogger.com/post-create.g?blogID=6158039503477645699"><br />
</a><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfP9oe4dqrNljdqTWeLMrBpP7LRZKJP0M2kLGLmpr3DOkJv5KLQR_AkLcGcgTfsaaLH_GruiBFYChrzw47EiP4f9ahOxFSoivGl_VOrDPyM-EXaaVXwuvELKaMLfMBxDrsGS7ml8WBL6Zo/s1600/Monkey+Color+Theme.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfP9oe4dqrNljdqTWeLMrBpP7LRZKJP0M2kLGLmpr3DOkJv5KLQR_AkLcGcgTfsaaLH_GruiBFYChrzw47EiP4f9ahOxFSoivGl_VOrDPyM-EXaaVXwuvELKaMLfMBxDrsGS7ml8WBL6Zo/s320/Monkey+Color+Theme.PNG" width="320" /></a></div><br />
<b>Color scheme import instructions</b><br />
<ol><li>Download the my color scheme from <a href="http://www.eclipsecolorthemes.org/?view=theme&id=1413">http://www.eclipsecolorthemes.org</a> or create your own.</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqaTID2Wjt7qk45gFEoLXGvUg6wDVv6N36s8k0vKiJaF_YcxYwdpKMkptBThjSjJQwq1sDuA_SdzMnT31bOqDnun53yNCna8LfX4WfnZnbTz-Jh1TTNKmFcqdy7dZDD8JiuOroX4XnswVV/s1600/Download+theme.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqaTID2Wjt7qk45gFEoLXGvUg6wDVv6N36s8k0vKiJaF_YcxYwdpKMkptBThjSjJQwq1sDuA_SdzMnT31bOqDnun53yNCna8LfX4WfnZnbTz-Jh1TTNKmFcqdy7dZDD8JiuOroX4XnswVV/s320/Download+theme.PNG" width="320" /></a></div><li>Choose "File" > "Import"</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCbpWtbxEcUcz6YMobrxf9s_uh8ffoZwE9teZBIhoCy0rFdkeZHR4lj6qsDrgxjb0vZlU6C5JRhAPt5nzT3fU5gMHmucpEu2tpMZHnaE0-oj-fZq-taKK6c4x5HkUuBO9XnmRqO8wYZznR/s1600/import+settings.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCbpWtbxEcUcz6YMobrxf9s_uh8ffoZwE9teZBIhoCy0rFdkeZHR4lj6qsDrgxjb0vZlU6C5JRhAPt5nzT3fU5gMHmucpEu2tpMZHnaE0-oj-fZq-taKK6c4x5HkUuBO9XnmRqO8wYZznR/s320/import+settings.PNG" width="261" /></a></div><li>Choose "Preferences" then "Next" </li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHExWXPWBPAbDqdXsZI9CqPL8FkbNq6czEzzLco3nsY0b_eK682p0asPggsTX-sQ0W-Yla1Oex4Iwsz_9q6O4qKKnh5566JWTh75up8HKpgdh1f6cSyZa4prEfuSB4qHH-J4L1lD1nC-ng/s1600/imort+preferences.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHExWXPWBPAbDqdXsZI9CqPL8FkbNq6czEzzLco3nsY0b_eK682p0asPggsTX-sQ0W-Yla1Oex4Iwsz_9q6O4qKKnh5566JWTh75up8HKpgdh1f6cSyZa4prEfuSB4qHH-J4L1lD1nC-ng/s320/imort+preferences.PNG" width="305" /></a></div><li>Browse to the ".epf" file you downloaded and select it.Then press "Finish".</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnHcZO9mw47EuZVIv397-3LQcpLEeApTd_xyynuRfxZEnvqeKVMvTDlz3tkJ5Q75irawLkbJkBd3YBg3MQFy2JaUYWChw2FsJ-r0Orkss2AkRvmOe33VPRGQa33nsLM5yehWngtWwEagYZ/s1600/imort+theme.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnHcZO9mw47EuZVIv397-3LQcpLEeApTd_xyynuRfxZEnvqeKVMvTDlz3tkJ5Q75irawLkbJkBd3YBg3MQFy2JaUYWChw2FsJ-r0Orkss2AkRvmOe33VPRGQa33nsLM5yehWngtWwEagYZ/s320/imort+theme.PNG" width="305" /></a></div></ol><div>And now your code window should immediately display your new color scheme.</div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaLelZ7egu3NG5wPx6Zx3mf5KuNyOhAGNrPJnGGMfi-gQ0yAfBr8gdM6A97PhifHWHI9dalMmMyoWEzFeTzcRcgbMdGlcIAMwnWZ-7bmQuBV7T4wPUHtzK9MdPBM_7WABlh3EldMYVCwoc/s1600/sample.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaLelZ7egu3NG5wPx6Zx3mf5KuNyOhAGNrPJnGGMfi-gQ0yAfBr8gdM6A97PhifHWHI9dalMmMyoWEzFeTzcRcgbMdGlcIAMwnWZ-7bmQuBV7T4wPUHtzK9MdPBM_7WABlh3EldMYVCwoc/s320/sample.PNG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><br />
<br />
<div><br />
</div>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com0tag:blogger.com,1999:blog-6158039503477645699.post-6170374319888959342011-03-03T20:55:00.001-07:002011-03-03T21:03:36.982-07:00Android app & Netduino plus to monitor and open garage door<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJKfaM5DYpjuFuK7JqCw_IOJqmV-jaoTFbxPw19Iz5gSmKnfFN0SHCSX7HHFIkgpposRmfvAJG1hICBS2VfsTSKZaaGZ-Gi0wz8kc4tkBT5WNqde2-K5zRTwg03mluFxSD0uLFH15VOyaT/s1600/netduino-plus.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJKfaM5DYpjuFuK7JqCw_IOJqmV-jaoTFbxPw19Iz5gSmKnfFN0SHCSX7HHFIkgpposRmfvAJG1hICBS2VfsTSKZaaGZ-Gi0wz8kc4tkBT5WNqde2-K5zRTwg03mluFxSD0uLFH15VOyaT/s1600/netduino-plus.png" /></a></div><br />
I have started a new blog on the Netduino plus board. This is my first foray into embedded programming. I just received an Arduino Uno board and a Netduino plus board. I am going to chronicle a home automation project that includes the following elements <i>(I will be documenting everything you need if you want to join me!) </i><br />
<br />
<ul><li>Netduino plus with garage door sensor</li>
<li>Open and close the garage door with the Netduino plus</li>
<li>Send commands to the Netduino over HTTP</li>
<li>A RESTful webservice that talks to the Netduino plus over HTTP</li>
<li>Write an Android app that talks to the RESTful webservice that talks to the Netduino</li>
<li>An Android app to monitor my garage door and open/close it.</li>
</ul><div>I will be posting every step of this project with parts lists, instructions and code examples. If you want to learn more here are some links.</div><div><ul><li><a href="http://netduinohacking.blogspot.com/">Blog about my embedded projects and code examples</a> (<a href="http://netduinohacking.blogspot.com/">http://netduinohacking.blogspot.com/</a>)</li>
<li><a href="http://www.arduino.cc/">Arduino (an open-source electronics prototyping platform)</a></li>
<li><a href="http://www.netduino.com/netduinoplus/specs.htm">Netduino plus</a></li>
</ul><div><br />
</div></div><div><br />
</div>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com1tag:blogger.com,1999:blog-6158039503477645699.post-14751718633395578872010-04-27T08:57:00.001-06:002010-05-02T07:12:56.171-06:00Comparing The Old & New Eclipse Theme .prefs Files<span style="color: red;">by Guest Contributor</span><span style="color: blue;"> </span><a href="http://www.blogger.com/profile/16665002727361413122" style="color: blue;">Bill Mote </a><br />
<br />
If you're wondering what's inside the 2 prefs files we replaced in the Eclipse themes post; here is a "compare" (or diff) using Eclipse's own built-in compare function. The files are human readable. The original unedited file is on the left in each image. Click each image to enlarge:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_ZAcZvN2QFEGDfj_h2L6oWZIsZIPITr_NelNdjHiGDDTXfD4ySlUwHg5glrqeW4BiRmMQ-T48L1MGOfXgcr8dZi_tpsuW3tNWfkbyyFNXzQw2whc3J_R7174r6EFUl5HmKVyaD_T3wdIF/s1600/compare_combined.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_ZAcZvN2QFEGDfj_h2L6oWZIsZIPITr_NelNdjHiGDDTXfD4ySlUwHg5glrqeW4BiRmMQ-T48L1MGOfXgcr8dZi_tpsuW3tNWfkbyyFNXzQw2whc3J_R7174r6EFUl5HmKVyaD_T3wdIF/s320/compare_combined.jpg" /></a></div><div style="text-align: center;"><b>org.eclipse.jdt.ui.prefs</b></div><br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzeYefc2B4I9g9vJWSg6ZssM9DvbLV4d3OcKCkdty9bTaq75pAJ84uS3yRzjuoozd2SspRWgzAO-L9qtHCzrAs5efqyRGgTwMUO0g3-q0XUUp5UApI1-BqvHbd94-Vih2pS_mVpv4kjFTG/s1600/compare3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzeYefc2B4I9g9vJWSg6ZssM9DvbLV4d3OcKCkdty9bTaq75pAJ84uS3yRzjuoozd2SspRWgzAO-L9qtHCzrAs5efqyRGgTwMUO0g3-q0XUUp5UApI1-BqvHbd94-Vih2pS_mVpv4kjFTG/s320/compare3.jpg" /></a></div><div style="text-align: center;"><b>org.eclipse.ui.editors.prefs</b></div><br />
<div style="text-align: center;"><br />
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-6158039503477645699.post-25687466420506881552010-04-26T17:39:00.010-06:002010-05-02T07:13:21.346-06:00Applying Themes to Eclipse<span class="Apple-style-span" style="color: red;">by Guest Contributor </span><span class="Apple-style-span" style="color: blue;"><a href="http://www.blogger.com/profile/16665002727361413122">Bill Mote</a></span><br />
<br />
<a href="http://androidcodemonkey.blogspot.com/2010/04/applying-themes-to-eclipse.html#HowTo">--> Skip to the How-To</a><br />
<br />
I'm new to event driven development. I stopped coding back when VB was in it's infancy. I did pickup classic ASP and do enough scripting in interpreted languages to kindle the desire, but it was not until the release of Android that I genuinely got on fire about coding again.<br />
<div><br />
</div><div><div style="text-align: center;"><div style="text-align: left;">What did I find? A lot of barriers. You wouldn't think that's true given the open and free nature of Android. Greg, aka Android Code Monkey, has put together an idiot proof tutorial on setting up the development environment. That was my first hurdle. Check. I moved on to his Hello Android tutorial. Check. Next I tried the Android Developer's NotepadCodeLab tutorial. Easy enough I thought. This time you just "open the AndroidCodeLab folder" as instructed and you're moving right along.</div></div></div><div><div style="text-align: left;"><br />
</div></div><div>Open it how? I tried various imports. I tried opening the source and various .xml files. All I did was build my frustration, but I'm not giving up. Instead I purchased "Head First Java." The book is awesome. It focuses on teaching Java and avoiding the IDE hurdles but I decided to code the examples in Notepad++ and Eclipse so I could be 1 step ahead when I finished. The leap from C++ to Java isn't that great and things seemed to make sense so I'm moving right along.</div><div><br />
</div><div>One thing I noticed about the Eclipse environment is how absolutely blinding it is! During the day it's tough enough, but at night, when I get most of my keyboard cycles for development, the open IDE is exhausting on my eyes. Another hurdle ...</div><div><br />
</div><div><a href="http://androidcodemonkey.blogspot.com/2010/04/applying-themes-to-eclipse.html#HowTo" name="HowTo">Cut to the chase already ...</a><br />
<br />
When Greg asked me to be a guest contributor I couldn't wait to get this information posted. I want to remove as many barriers as I can for new developers like myself!</div><div><br />
</div><div>My first searches for Eclipse and Themes didn't produce much and the information that was available was, or at least seemed, convoluted and complicated. Turns out changing the themes in Eclipse is very, very easy!</div><div><br />
</div><div>There are 2 files used to display the themes:</div><div><br />
</div><div>Colors are managed in this file: <b>org.eclipse.jdt.ui.prefs</b></div><div>Text Editors are managed in this file: <b>org.eclipse.ui.editors.prefs</b></div><div><br />
</div><div>Those files can be found below your Eclipse workspace folder which can be found here:</div><div><br />
</div><div>Windows -- <b>.metadata\.plugins\org.eclipse.core.runtime\.settings</b></div><div>Linux/MAC -- <b>.metadata/.plugins/org.eclipse.core.runtime/.settings/</b></div><div><br />
</div><div>I found an <a href="http://dc98.2shared.com/download/7073148/25af5556/eclipse-themes.zip?tsid=20100426-141820-180964b4">archive file with 6 different themes</a> including the "default" to easily undo any of your changes. Here's what they look like:</div><div><br />
</div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkh8YmVK9-u4TyM-UQkEG3x2hyphenhyphenjf8VXCKPe1uOzWPDNy3h_OI05g0fWPLkpZ6zG1lWSmvZyLudQ5bExVjO5-Lqef0Ph_SdzWnPMnD2r5qjfifvYcHVKu9kpttLTIgswyhazA8mfiFsgHU/s1600/inkpot.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkh8YmVK9-u4TyM-UQkEG3x2hyphenhyphenjf8VXCKPe1uOzWPDNy3h_OI05g0fWPLkpZ6zG1lWSmvZyLudQ5bExVjO5-Lqef0Ph_SdzWnPMnD2r5qjfifvYcHVKu9kpttLTIgswyhazA8mfiFsgHU/s320/inkpot.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;">Inkpot</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW4o9dD5v4L2DK3KNHg1lyb6K2yiqOUzZtYQnCUgKAo817BxpWB1tcqEPCuThiS8p7-64jgmODea-yQY-A2xnzOanaxAq08ukJqbkv-lYoAd0wyoPk6pE8sIkLbZoI8BL-vHCcsd0Zxpk0/s1600/sula.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW4o9dD5v4L2DK3KNHg1lyb6K2yiqOUzZtYQnCUgKAo817BxpWB1tcqEPCuThiS8p7-64jgmODea-yQY-A2xnzOanaxAq08ukJqbkv-lYoAd0wyoPk6pE8sIkLbZoI8BL-vHCcsd0Zxpk0/s320/sula.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;">Sula</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEtN5GZ3qiLHwB_FMfp3h-tFpNKPAWjBj2GePMtKYiEbYvl0p102cVSGE4tJGyxn3za0qy9VF49r7qJIuPtQSUN7lfJVdjIk2-D6xyV7iPAZpiewceKn9fxXlAwo4zYol7U9M3UmMVuSfo/s1600/vibrantink.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEtN5GZ3qiLHwB_FMfp3h-tFpNKPAWjBj2GePMtKYiEbYvl0p102cVSGE4tJGyxn3za0qy9VF49r7qJIuPtQSUN7lfJVdjIk2-D6xyV7iPAZpiewceKn9fxXlAwo4zYol7U9M3UmMVuSfo/s320/vibrantink.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;">Vibrant Ink</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioAzyKHotzP6eCf3Qiu-JWh0Ejw3ook3BKw-3WkD1xYuLf9kfW81MtWzOXEbh4j2QATWNPsKOWpDJQwf7QhkyzSQKJfAGSFivjCIwJTg-1FfelGZ4ftLSYeaeQtz2MEKLkg_yYvwlJak_P/s1600/wombat.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioAzyKHotzP6eCf3Qiu-JWh0Ejw3ook3BKw-3WkD1xYuLf9kfW81MtWzOXEbh4j2QATWNPsKOWpDJQwf7QhkyzSQKJfAGSFivjCIwJTg-1FfelGZ4ftLSYeaeQtz2MEKLkg_yYvwlJak_P/s320/wombat.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;">Wombat</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYcgAjj-oQnI-f_F9Qq3daod1rgbAuSQcAqWB1oIPucR9sB7CnpmSP_h77uOABuU9aMU-ZK1hsyXCukYIPLo1IqrpjY_kPG2tLwE3D2Lc7WhBaYwPH-V-fb5VbqWJdyoVOQ0YS6p3uD1_5/s1600/zenburn.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYcgAjj-oQnI-f_F9Qq3daod1rgbAuSQcAqWB1oIPucR9sB7CnpmSP_h77uOABuU9aMU-ZK1hsyXCukYIPLo1IqrpjY_kPG2tLwE3D2Lc7WhBaYwPH-V-fb5VbqWJdyoVOQ0YS6p3uD1_5/s320/zenburn.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;">Zenburn</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">The archive contains the 6 images and 6 folders; 1 for each theme. In each folder you'll find the 2 aforementioned files. Simply extract the 2 files from your desired theme into the appropriate Eclipse folder as described above and launch Eclipse!</div></div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-6158039503477645699.post-85127948056474082352010-03-15T22:51:00.000-06:002010-03-15T22:51:11.498-06:00Getting Started with Android DevelopmentYou want to be begin Android Application Development. But how do you get started? The first thing you need is to download and install the development tools. The good news is they are free and fairly straightforward to setup. The bad news is there are so many options it can become confusing which tools are required, optional or compatible with your desired setup. Following the setup I am using and will work for you if you using a Windows system. <br />
<br />
Step 1. Install the following tools<br />
<ul><li>Eclipse IDE for Java Developers<i> (v3.5 Galileo) </i></li>
<li>Java Platform <i>(JDK 6 Update 18)</i><br />
</li>
<li> Android SDK Tools, Revision 4</li>
</ul>You can follow my previous post for step by step directions (with screen captures) <a href="http://androidcodemonkey.blogspot.com/2010/01/how-to-setup-android-development_23.html">here</a>.<br />
<br />
Step 2. Create your first application. Try my Hello World tutorial <a href="http://androidcodemonkey.blogspot.com/2010/01/hello-world-your-first-android.html">here</a>.<br />
<br />
Feel free to post questions or comments.Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com0tag:blogger.com,1999:blog-6158039503477645699.post-28790074972201063942010-03-08T19:00:00.004-07:002011-03-09T20:38:51.823-07:00How to base64 encode decode AndroidThe official documentation states that base64 encode and decode in Android is in the Android.util package. But when you go to use it you will find it's not there!<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhup3wYkoSD7Qhx10S5rSdeBVcP_fmDKWsGJZVlaSGAer4QkWTGjccYQI7VWa1xo54jFzyu-Fko7YDI6v9TYWN8CXbCkvXmqYCPimEgZPAZgmAzQ5YlLRFiqFivXsS4A7tQ4mPEGq1DUoRY/s1600-h/base641.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhup3wYkoSD7Qhx10S5rSdeBVcP_fmDKWsGJZVlaSGAer4QkWTGjccYQI7VWa1xo54jFzyu-Fko7YDI6v9TYWN8CXbCkvXmqYCPimEgZPAZgmAzQ5YlLRFiqFivXsS4A7tQ4mPEGq1DUoRY/s320/base641.PNG" /></a></div><br />
After much searching, I confirmation Android left base64 encode and decode out of the Android.util package. So what to do? Don't worry, Robert W. Harder has but together a very fast Base64 encoding and decoding class you can include in your project. Here is how to add base64 encode and decode to your project.<br />
<br />
<b>Step 1.</b> Visit Robert's website <a href="http://iharder.sourceforge.net/current/index.html">http://iharder.sourceforge.net/current/index.html</a> and download the class file.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVcFcwy8OJIij3Ts7ns33zXM4WPxpMOBXmXlulR2zUXQ_6S2ZFKUbTdyfmPJTG-fIjD-PUpaI3Qo_VeWCQhmP1EQVw-qxfFx65JaIUrWqCQinKc4jngdeLZZbNDUQeT7Mw3zQgkJVH6RqO/s1600-h/base64-2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVcFcwy8OJIij3Ts7ns33zXM4WPxpMOBXmXlulR2zUXQ_6S2ZFKUbTdyfmPJTG-fIjD-PUpaI3Qo_VeWCQhmP1EQVw-qxfFx65JaIUrWqCQinKc4jngdeLZZbNDUQeT7Mw3zQgkJVH6RqO/s320/base64-2.PNG" /></a> </div><b>Step 2.</b> The zip file you downloaded in step 1 includes the base64 class and a folder with examples and documentation.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwHrAv7AnHCXFszq-YWdzSKTK3bgA8_P5znZL6L7imABeno7ZFg-rB7Ev3r40VhAyx21J4msRr3S76R2bUeWsJptf2tg-AslfB7JtNVXjKKiCSrxyRQavSA_wWjMcZEQFaKxjhvt-B5kyu/s1600-h/base64-3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwHrAv7AnHCXFszq-YWdzSKTK3bgA8_P5znZL6L7imABeno7ZFg-rB7Ev3r40VhAyx21J4msRr3S76R2bUeWsJptf2tg-AslfB7JtNVXjKKiCSrxyRQavSA_wWjMcZEQFaKxjhvt-B5kyu/s320/base64-3.PNG" /></a> </div><b>Step 3. </b>Copy the Base64.java class file into your project. Copy into your appropriate "src" folder.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXUohDJhzrVDeazr9uDlzOb5D04H6C2JLRxJu0zH2z4kchhms1LwSwdGRuC_2lCo46Xc8PTPyZj0xhI812wWWVkFRV36uCQMN3ijgb1UKDflV8ikk5EkEzcZP_KHzVwCup7KF0fwoZ1jfU/s1600-h/base64-4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXUohDJhzrVDeazr9uDlzOb5D04H6C2JLRxJu0zH2z4kchhms1LwSwdGRuC_2lCo46Xc8PTPyZj0xhI812wWWVkFRV36uCQMN3ijgb1UKDflV8ikk5EkEzcZP_KHzVwCup7KF0fwoZ1jfU/s320/base64-4.PNG" /></a></div><b>Step 4.</b> Refresh your project so the new file is included.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEvATZsU1l_Wc4sgPXkv4Ov7h9GRcdcf0d5CiWs8H2IZlIcKpM4E-DIHcpqKb5KyU_pCfIP8b4ZqJ-kjEnNACkCEeHxvIafbpBaXD7DxdccwaD9dOc7f50Cjt_PR_-E7lOlglipNQvYeUY/s1600-h/base64-5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEvATZsU1l_Wc4sgPXkv4Ov7h9GRcdcf0d5CiWs8H2IZlIcKpM4E-DIHcpqKb5KyU_pCfIP8b4ZqJ-kjEnNACkCEeHxvIafbpBaXD7DxdccwaD9dOc7f50Cjt_PR_-E7lOlglipNQvYeUY/s320/base64-5.PNG" /></a></div><b>Step 5.</b>When the Base64.java file is included in your project, you will get the following error "The declared package does not match the expected package". Fix this by opening the class file and adding a package declaration that matches your project.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv56PpMNkxXhyphenhyphenHr22NdOCLgk9i9_ctNOZtjUVHoHBMa4bSU_ufgq136sXVje_tEoS2ffbT9oka0uL0BCEcZp3NE0uT7L3g7P05MsdPD3LcgDDnGxiMoGd8_SxaLYjsJU07UaBBWZu9k-Tz/s1600-h/base64-6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv56PpMNkxXhyphenhyphenHr22NdOCLgk9i9_ctNOZtjUVHoHBMa4bSU_ufgq136sXVje_tEoS2ffbT9oka0uL0BCEcZp3NE0uT7L3g7P05MsdPD3LcgDDnGxiMoGd8_SxaLYjsJU07UaBBWZu9k-Tz/s320/base64-6.PNG" /></a></div><b>Step 6.</b> Done. You're ready to base64 encode and decode.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhReM-QKkMbdJu7zZaaUtwyoVmsmHdNxYW-6jH97ZvRvXJknHQ-yqKrXKweu1_0ZS77u5ftZgjOx9egJxCr_msyoDoR-XY7kuM36diJREr-LnbS03UIGdS4k-Vn-qTuCvlOnGl4MI3xQSyo/s1600-h/base64-7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhReM-QKkMbdJu7zZaaUtwyoVmsmHdNxYW-6jH97ZvRvXJknHQ-yqKrXKweu1_0ZS77u5ftZgjOx9egJxCr_msyoDoR-XY7kuM36diJREr-LnbS03UIGdS4k-Vn-qTuCvlOnGl4MI3xQSyo/s320/base64-7.PNG" /></a> </div><br />
Download the complete tutorial here<br />
<iframe title ="Preview" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" style="width:98px;height:115px;padding:0;background-color:#fcfcfc;" src="http://cid-369caadcbdc49509.office.live.com/embedicon.aspx/Blog%20Files/Base64Test.zip"></iframe>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com17tag:blogger.com,1999:blog-6158039503477645699.post-7107979842148478192010-03-06T11:21:00.000-07:002010-03-06T11:21:11.773-07:00Vidoes - My First Android Application in the Market<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRCEg4t_qw6Ri13m-1L1LWFfel3Mm547ICj26y1Q3V0s0DJshpgPTZxVx8MQehpfd4HcBMYwflwKrydY1Yd9GQH0BaY544AVW2arstox1r0EDZ41sAwIpXRkcuBXFHJv25jep73ohBvutf/s1600-h/icon.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRCEg4t_qw6Ri13m-1L1LWFfel3Mm547ICj26y1Q3V0s0DJshpgPTZxVx8MQehpfd4HcBMYwflwKrydY1Yd9GQH0BaY544AVW2arstox1r0EDZ41sAwIpXRkcuBXFHJv25jep73ohBvutf/s320/icon.png" /></a></div>My first Android application is now in the Market. Why did I create this application? Frankly, because it's missing from Android OS. There is a music application for listening to your music. But, to view your videos you must launch the gallery and view your videos mixed in with your pictures. Also, you don't get the video title or video length. <br />
<br />
The "Videos" application fills this void with a simple scrolling list of just the videos on your phone. The features of the application:<br />
<ul><li>Thumbnail of your videos</li>
<li>Video name</li>
<li>Video length</li>
<li>Time left (if you are in the middle of watching a video)</li>
<li>Launch the video</li>
</ul><div class="separator" style="clear: both; text-align: center;"></div><br />
If you have an Android 2.0+ phone you can find it in the market by searching "Videos" or get more information <a href="http://www.androidcodemonkey.com/videos-android-app">here</a>.<br />
<br />
<table border="0"><tbody>
<tr> <td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4k4YM1UERTd6oipXpMAsdYRXdYY-zShK6iJpygvDcwqwlucayAXv1d3T7I0ERvVQEQ2x3xyyRdDN9gwENkgqh4KE6LKeqq1KZ3YHb1VgpANxksWWq-NL_8r-d_Vm7rp4Mnw4wKSa85WZm/s1600-h/Videos1.jpg" target="_blank" title="Videos screen capture"><br />
<img alt="Videos screen capture" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4k4YM1UERTd6oipXpMAsdYRXdYY-zShK6iJpygvDcwqwlucayAXv1d3T7I0ERvVQEQ2x3xyyRdDN9gwENkgqh4KE6LKeqq1KZ3YHb1VgpANxksWWq-NL_8r-d_Vm7rp4Mnw4wKSa85WZm/s200/Videos1.jpg" width="150" /></a></td> <td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyC7VCO6zrZjyWbFqr4dZyg1VVEFtRXLuEGMQjxfeB4n6RhMduqS-WDFSBfbjI-iNGfDbGrx0mcCvhH3YV7JWRo5oHGjuDt-z6z8ei3cPafbYWO9E4UzWAXc2Xtcffclgunw5ycsthei-6/s1600-h/Videos2.jpg" target="_blank" title="Videos screen capture"><br />
<img alt="Videos screen capture" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyC7VCO6zrZjyWbFqr4dZyg1VVEFtRXLuEGMQjxfeB4n6RhMduqS-WDFSBfbjI-iNGfDbGrx0mcCvhH3YV7JWRo5oHGjuDt-z6z8ei3cPafbYWO9E4UzWAXc2Xtcffclgunw5ycsthei-6/s200/Videos2.jpg" width="150" /></a></td> </tr>
</tbody></table>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com3tag:blogger.com,1999:blog-6158039503477645699.post-24418860897010008902010-02-06T00:29:00.026-07:002011-03-09T20:36:35.775-07:00Tutorial: Listview<h1>Android "To Do" Application Tutorial</h1>This is Part 1 in a series of tutorials. Each will build on the previous covering concepts which should be transferable to many applications. In order to cover many typical coding requirements, we are going to create a simple "To Do" application. Each tutorial part will conclude with a functioning application, albeit incomplete. In these series of tutorials we will cover adding, editing, and deleting items in a ListView. Here is what this series of tutorials will cover: <br />
<ul><li>Start a new Android application.</li>
<li>Add, edit, and delete items in a ListView.</li>
<li>Edit "To Do" form.</li>
<li>We will start with a simple "one line" ListView. Then we will upgrade it so we can customize and dress up each row. </li>
<li>We will add some graphics to the ListView.</li>
<li>To improve performance and encapsulation we will move To Do items into a separate class that can cache the TextView and ImageView widgets.</li>
<li>Create a landscape layout.</li>
<li>Create a database and table to store our tasks.</li>
</ul><span style="font-size: large;"><b> Part 1: Create a new project</b></span><br />
<span style="font-size: large;"><b></b></span><br />
<span style="font-size: large;"><span style="font-size: small;"><br />
</span></span><br />
<span style="font-size: large;"><span style="font-size: small;">1. Create new project<br />
</span></span><br />
<ol><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGXadlzc7FmFBLxN8mEo3AmMEqrorBLNg7I5UPscV2GnMy-DSWnZgYUTa-yuWTs_FSqXaaYLw885BpDdJdK64FDoV0aPrvETMEPdTbvIQruICa3MRFpwLKFHv7nHZLTOMAGWSC44SXiM4/s1600-h/NewProject.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPGXadlzc7FmFBLxN8mEo3AmMEqrorBLNg7I5UPscV2GnMy-DSWnZgYUTa-yuWTs_FSqXaaYLw885BpDdJdK64FDoV0aPrvETMEPdTbvIQruICa3MRFpwLKFHv7nHZLTOMAGWSC44SXiM4/s320/NewProject.PNG" /></a><span style="font-size: large;"><span style="font-size: small;"> </span></span><span style="font-size: large;"><span style="font-size: small;"></span></span></div></ol><span style="font-size: large;"><span style="font-size: small;">2. Select "Android Application". Select "Next"</span></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2dn0U3porHDJZzYl84XEOj4DCCsbHlBZ76bi-0q3PNbWjYb54oQri0Pb3VyqY9kqNy0MO8DDK9X87XXgPHlCrtjx4YQWwglmXKZHtLmrejEJLhxZG7xlSD93Ekp6W4dcrVisraBY_PhGo/s1600-h/NewProject2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2dn0U3porHDJZzYl84XEOj4DCCsbHlBZ76bi-0q3PNbWjYb54oQri0Pb3VyqY9kqNy0MO8DDK9X87XXgPHlCrtjx4YQWwglmXKZHtLmrejEJLhxZG7xlSD93Ekp6W4dcrVisraBY_PhGo/s320/NewProject2.PNG" /></a></div><span style="font-size: large;"><span style="font-size: small;"> </span></span><br />
<span style="font-size: large;"><span style="font-size: small;">3. Set</span></span><span style="font-size: large;"><span style="font-size: small;"> new project properties the click "Finish"</span></span><br />
<ul><li><b>Project Name:</b> To Do Tutorial</li>
<li><b>Build Target: </b>Select Android 2.1<i> (you may select any build target, but this tutorial is 2.1)</i></li>
<li><b>Application Name:</b> To Do Tutorial</li>
<li><b>Package Name: </b>org.androidcodemonkey.todo</li>
<li><b>Create Activity: </b>DetailForm</li>
<li><b>Min SDK: </b><i>7 (leave the default) </i></li>
</ul><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLr6-WmcrBv6YfHH84gS-At2njBoPWUz0CaMULdexjzaizUQlLMeWjxEo4aMvkzlsiDs0fueUwg3OTCpGhQJHWqCAhgiy7idxH2YBWq_EA5vBd2vBlPRTQfGaJZzQiaFCdwuln8YEj9hLc/s1600-h/NewProject3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLr6-WmcrBv6YfHH84gS-At2njBoPWUz0CaMULdexjzaizUQlLMeWjxEo4aMvkzlsiDs0fueUwg3OTCpGhQJHWqCAhgiy7idxH2YBWq_EA5vBd2vBlPRTQfGaJZzQiaFCdwuln8YEj9hLc/s320/NewProject3.PNG" /></a></div>4. Open layout "main.xml"<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHwLkpIPbQqhlzkl2vgGbcRoElV284QRD-WjQILYPE945c_xTfQIlDjGIUXtYrXfjJoyEHk5mZ3FuH2mzRNWQMjBxawyBOxd6LxPlz-CLYMWJoKEVqCKpUqdiXyWsxzr5VuWqm_KN-gIbL/s1600-h/layout1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHwLkpIPbQqhlzkl2vgGbcRoElV284QRD-WjQILYPE945c_xTfQIlDjGIUXtYrXfjJoyEHk5mZ3FuH2mzRNWQMjBxawyBOxd6LxPlz-CLYMWJoKEVqCKpUqdiXyWsxzr5VuWqm_KN-gIbL/s320/layout1.PNG" /></a></div><br />
5. Right click on "Hello World, DetailForm!" and select "Remove"<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg81m7GwgF3MFwM_WYsQy_Sv_Z1CQtyTxVypGU6VePU5Ti7zE9n7His6XGtzFgT7t2kfxIU7LFTR2yn5lFqNZXe0VyyI_Zo5CYJqdwPCTylbmURyheuq1EYs-11Byh1bhqeyrKcfdctmzZM/s1600-h/layout2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg81m7GwgF3MFwM_WYsQy_Sv_Z1CQtyTxVypGU6VePU5Ti7zE9n7His6XGtzFgT7t2kfxIU7LFTR2yn5lFqNZXe0VyyI_Zo5CYJqdwPCTylbmURyheuq1EYs-11Byh1bhqeyrKcfdctmzZM/s320/layout2.PNG" /></a></div>6. Now we are going to modify our layout. You can drag controls onto the layout in "Layout" mode, but I prefer to edit the XML directly. It provides me greater control. I am going to add the following controls in the XML mode<i> (add the code from lines 2-26)</i>:<br />
<ul><li>TableLayout</li>
<ul><li>TableRow</li>
<ul><li>TextView</li>
<li>EditText</li>
</ul><li>TableRow</li>
<ul><li>TextView</li>
<li>RadioGroup</li>
<ul><li>RadioButton</li>
<li>RadioButton</li>
<li>RadioButton</li>
</ul></ul><li>TableRow</li>
<ul><li>TextView</li>
<li>Button</li>
</ul></ul></ul><pre class="brush: xml; highlight: [2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26] "><linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<tablelayout android:id="@+id/TableLayout01" android:layout_alignparentbottom="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:stretchcolumns="1">
<tablerow>
<textview android:text="Task">
<edittext android:id="@+id/txtTask">
</edittext>
<tablerow>
<textview android:text="Priority:">
<radiogroup android:id="@+id/priority">
<radiobutton android:id="@+id/highPriority" android:text="High">
<radiobutton android:id="@+id/medPriority" android:text="Medium">
<radiobutton android:id="@+id/lowPriority" android:text="Low">
</radiobutton>
</radiobutton>
<tablerow>
<textview>
<button android:id="@+id/btnSave" android:text="Save">
</button></textview>
</tablerow>
</radiobutton>
</radiogroup>
</textview>
</tablerow>
</textview>
</tablerow>
</tablelayout>
</linearlayout>
</pre><br />
7. Change to LayoutView and it should look like this. Feel free to change settings on the display to see how it affects the controls.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGRViem4Xz5FzMgg5RVCJlKWZb9nDUrhWiZeWAUESoqk17WreR0jgEwSpvsOWkRGwkBL8Z-fXeCxrxR5XpMbhUSbOf9hCR06X55ynj7bA5S_PpHsJm4CQhIRxqM2QQu4LBP22cQE8ym7jA/s1600-h/layout3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGRViem4Xz5FzMgg5RVCJlKWZb9nDUrhWiZeWAUESoqk17WreR0jgEwSpvsOWkRGwkBL8Z-fXeCxrxR5XpMbhUSbOf9hCR06X55ynj7bA5S_PpHsJm4CQhIRxqM2QQu4LBP22cQE8ym7jA/s320/layout3.PNG" /></a> </div>8. Now we need an "entity" class. To keep our class files organized, let's create package.<br />
<ul><li>In the Package Explorer > Right click on "src" > "New" > "Package"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKld5wzoJ9YYXgUkAnkhYCqjoaatBJvUcTH-_IPQ0Q3WaCiQMU40adi81HMRg_MDoGwby5LdZ9C1B9A7vWoPAcp3kd00Qcbqg_OjfDyPAcHtScWViNSo-lYr-lyk5QkJQluojsEFrJAtaj/s1600-h/NewPackage1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKld5wzoJ9YYXgUkAnkhYCqjoaatBJvUcTH-_IPQ0Q3WaCiQMU40adi81HMRg_MDoGwby5LdZ9C1B9A7vWoPAcp3kd00Qcbqg_OjfDyPAcHtScWViNSo-lYr-lyk5QkJQluojsEFrJAtaj/s320/NewPackage1.PNG" /></a></div><br />
<ul><li>Name: "org.androidcodemonkey.entities" Then click "Finish"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0ghR47zris4J_dpRaYmHpGA83yO20jXYbj-lbW-gPgQfwnKteMQ5Nux4Cq6obJjXpofZaDDonCE9KYO3DZ3CmGitF8-a-VEtYTUYrC3wY0WyEsMPFrYaViQ38rwZpwvqwIlYCbbV8XbkL/s1600-h/NewPackage2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0ghR47zris4J_dpRaYmHpGA83yO20jXYbj-lbW-gPgQfwnKteMQ5Nux4Cq6obJjXpofZaDDonCE9KYO3DZ3CmGitF8-a-VEtYTUYrC3wY0WyEsMPFrYaViQ38rwZpwvqwIlYCbbV8XbkL/s320/NewPackage2.PNG" /></a></div>9. Let's add the a class for our "Task"<br />
<ul><li>In the Package Explorer > Right click on "org.androidcodemonkey.entities" > "New" > "class"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje3SvJtbGc_tuGEYpoSnisvB9Q6KQ0LK1COwusEsmcFT2K5HKmPddGpeap5hWOLGeDykMMP0A9WpVAHvNqsQ0jYoF-KgQjot0EyrsHbZ6WIBCe7V22ZDZdMVMkqSr84BfJCXLEKG6hCsDq/s1600-h/NewClass.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEje3SvJtbGc_tuGEYpoSnisvB9Q6KQ0LK1COwusEsmcFT2K5HKmPddGpeap5hWOLGeDykMMP0A9WpVAHvNqsQ0jYoF-KgQjot0EyrsHbZ6WIBCe7V22ZDZdMVMkqSr84BfJCXLEKG6hCsDq/s320/NewClass.PNG" /></a></div><ul><li>Name: TaskBE. Click "Finish"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQSiUYCrHjgXmc2Go43lusW6EoTKuGH7qWCv05irOfVm0UuxzcElTDmZCVxT46r2ohJo0mXyIAnS6EqA_SbM9ymDYxYF2n1f9K59p-IxOqP6_Pbj5PKo3XG9TnLeygD4XJyq7S7jEdJ_Oq/s1600-h/NewClass2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQSiUYCrHjgXmc2Go43lusW6EoTKuGH7qWCv05irOfVm0UuxzcElTDmZCVxT46r2ohJo0mXyIAnS6EqA_SbM9ymDYxYF2n1f9K59p-IxOqP6_Pbj5PKo3XG9TnLeygD4XJyq7S7jEdJ_Oq/s320/NewClass2.PNG" /></a></div>10. Create the following properties and methods.<br />
<ul><li>Create string "item"</li>
<li>Create string "priority"</li>
<li>Create getItem() </li>
<li>Create setItem()</li>
<li> Create getPriority()</li>
<li>Create setPriority()</li>
<li>Implement "toString()". </li>
</ul>Your TaskBE class should look like this:<br />
<br />
<pre class="brush: java; ">package org.androidcodemonkey.entities;
public class TaskBE {
private String item="";
private String priority="";
public String getItem() {
return(item);
}
public void setItem(String value) {
this.item = value;
}
public String getPriority() {
return(priority);
}
public void setType(String value) {
this.priority = value;
}
public String toString() {
return(getItem());
}
}
</pre>11. Open DetailForm.java. We are going to add an "onSave" method that will be called when the save button is pressed. When the save button is pressed we are going to retrieve the information from the View.<br />
<ul><li>Import reference to entities<i> (line #3) </i></li>
<li>Create a new TaskBE object. <i>(line #20) </i></li>
<li>Create an EditText to retrieve the item entered into the view <i>(line #21)</i></li>
<li>Set the item property of the Task <i>(line #22)</i></li>
<li>Create a RadioGroup to retrieve the priority <i>(line #23)</i></li>
<li>Set the priority property of the task<i> (lines #24-#34)</i></li>
<li><i>(In the next post we will implement adding the task to an adapter) (line #35)</i></li>
<li>Clear the controls on View <i>(lines #37-#38)</i></li>
</ul><pre class="brush: java; highlight: [3,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40] ">package org.androidcodemonkey.todo;
import org.androidcodemonkey.entities.*;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioGroup;
public class DetailForm extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
TaskBE newTask =new TaskBE();
EditText taskItem=(EditText)findViewById(R.id.txtTask);
newTask.setItem(taskItem.getText().toString());
RadioGroup priorityGroup=(RadioGroup)findViewById(R.id.priority);
switch (priorityGroup.getCheckedRadioButtonId()) {
case R.id.highPriority:
newTask.setType("high_priority");
break;
case R.id.medPriority:
newTask.setType("med_priority");
break;
case R.id.lowPriority:
newTask.setType("low_priority");
break;
}
//To do - Add task to adapter. To be implemented in next post
//Clear form
taskItem.setText("");
priorityGroup.clearCheck();
}
};
}
</pre>12. Now when the form is created we need instantiate a button and set it to the save button <i>(line #18)</i> and register a callback for when the button is pressed <i>(line #19)</i>.<br />
<pre class="brush: java; highlight: [18,19]">package org.androidcodemonkey.todo;
import org.androidcodemonkey.entities.*;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
public class DetailForm extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnSave = (Button)findViewById(R.id.btnSave);
btnSave.setOnClickListener(onSave);
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
TaskBE newTask =new TaskBE();
EditText taskItem=(EditText)findViewById(R.id.txtTask);
newTask.setItem(taskItem.getText().toString());
RadioGroup priorityGroup=(RadioGroup)findViewById(R.id.priority);
switch (priorityGroup.getCheckedRadioButtonId()) {
case R.id.highPriority:
newTask.setType("high_priority");
break;
case R.id.medPriority:
newTask.setType("med_priority");
break;
case R.id.lowPriority:
newTask.setType("low_priority");
break;
}
//To do - Add task to adapter. To be implemented in next post
//Clear form
taskItem.setText("");
priorityGroup.clearCheck();
}
};
}
</pre>13. You can now run the program. When you click "Save" your controls should be cleared. Your screen should look like this<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbyFLtJDUhqsMbvsNgQyr7_5b3ONaT3HF0w6MpIkg4zHr9jLM0kZWXRsiXhcAComppNjWuHr43eQ7j1KH4mPyXwK53bb3hyphenhyphen13TJX-bldxSQzNjUeZ43qOOheFomLck2OUf1cp-hmfuAg99/s1600-h/ToDo-screen-cap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbyFLtJDUhqsMbvsNgQyr7_5b3ONaT3HF0w6MpIkg4zHr9jLM0kZWXRsiXhcAComppNjWuHr43eQ7j1KH4mPyXwK53bb3hyphenhyphen13TJX-bldxSQzNjUeZ43qOOheFomLck2OUf1cp-hmfuAg99/s320/ToDo-screen-cap.png" /></a></div><span style="font-size: large;"><b><br />
</b></span><br />
<span style="font-size: large;"><b>Following is the complete code</b></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div>Download zip file of complete Eclipse project<br />
<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-369caadcbdc49509.office.live.com/embedicon.aspx/Blog%20Files/ToDoTutorial.zip" style="background-color: #fcfcfc; height: 115px; padding: 0; width: 98px;" title="Preview"></iframe><br />
<br />
<div></div><br />
<br />
<br />
<b>DetailFrom.java</b><br />
<pre class="brush: java; "><a href="http://www.blogger.com/post-edit.g?blogID=6158039503477645699&postID=2441886089701000890">package org.androidcodemonkey.todo;
import org.androidcodemonkey.entities.*;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
public class DetailForm extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnSave = (Button)findViewById(R.id.btnSave);
btnSave.setOnClickListener(onSave);
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
TaskBE newTask =new TaskBE();
EditText taskItem=(EditText)findViewById(R.id.txtTask);
newTask.setItem(taskItem.getText().toString());
RadioGroup priorityGroup=(RadioGroup)findViewById(R.id.priority);
switch (priorityGroup.getCheckedRadioButtonId()) {
case R.id.highPriority:
newTask.setType("high_priority");
break;
case R.id.medPriority:
newTask.setType("med_priority");
break;
case R.id.lowPriority:
newTask.setType("low_priority");
break;
}
//To do - Add task to adapter. To be implemented in next post
//Clear form
taskItem.setText("");
priorityGroup.clearCheck();
}
};
}
</a></pre><a href="http://www.blogger.com/post-edit.g?blogID=6158039503477645699&postID=2441886089701000890"><b>TaskBE.java</b><br />
</a><br />
<pre class="brush: java;"><a href="http://www.blogger.com/post-edit.g?blogID=6158039503477645699&postID=2441886089701000890">package org.androidcodemonkey.entities;
public class TaskBE {
private String item="";
private String priority="";
public String getItem() {
return(item);
}
public void setItem(String value) {
this.item = value;
}
public String getPriority() {
return(priority);
}
public void setType(String value) {
this.priority = value;
}
public String toString() {
return(getItem());
}
}
</a></pre><pre class="brush: xml; "><linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<a href="http://www.blogger.com/post-edit.g?blogID=6158039503477645699&postID=2441886089701000890"> <tablelayout android:id="@+id/TableLayout01" android:layout_alignparentbottom="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:stretchcolumns="1">
<tablerow>
<textview android:text="Task">
<edittext android:id="@+id/txtTask">
</edittext>
<tablerow>
<textview android:text="Priority:">
<radiogroup android:id="@+id/priority">
<radiobutton android:id="@+id/highPriority" android:text="High">
<radiobutton android:id="@+id/medPriority" android:text="Medium">
<radiobutton android:id="@+id/lowPriority" android:text="Low">
</radiobutton>
</radiobutton>
<tablerow>
<textview>
<button android:id="@+id/btnSave" android:text="Save">
</button></textview>
</tablerow>
</radiobutton>
</radiogroup></textview></tablerow></textview></tablerow></tablelayout></a></linearlayout></pre><a href="http://www.blogger.com/post-edit.g?blogID=6158039503477645699&postID=2441886089701000890"><br />
</a>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com16tag:blogger.com,1999:blog-6158039503477645699.post-76347109817673732882010-01-26T21:46:00.001-07:002011-07-27T15:30:05.623-06:00How to take Android Screen ShotCurrently, there are no applications available to take a screen capture for Android. This is a step by step guide to take a screen captures.<br />
<br />
Step 1: Install Java Platform <i>(JDK 6 Update 18)</i><br />
<ul><li>If you have not already installed JAVA follow the instructions in <a href="http://androidcodemonkey.blogspot.com/2010/01/how-to-setup-android-development_23.html">Step 2 of my previous post.</a> </li>
</ul>Step 2: Install the Android SDK Tools, Revision 4<br />
<ul><li> If you have not already installed the Android SDK follow the instructions in <a href="http://androidcodemonkey.blogspot.com/2010/01/how-to-setup-android-development_23.html">Step 3 and Step 4 of my previous post.</a><br />
</li>
</ul>Step 3: Configure your Nexus one<br />
<ul><li>From your home screen (pictured below) press "Launcher" icon to view all applications.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6JugTkptWTv89KeWdNaQvHFABpspQaKEdj5F_SXDJWRRowT8fhnvAh1tvN4Z2ziNENiPd8FjxGXXGCYaXEfrjFHQ8iK1ieHX6wRfDn8ow9yporeVp5uPj9shYIjdEXaNT37gwQHO6QS_-/s1600-h/homescreen.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6JugTkptWTv89KeWdNaQvHFABpspQaKEdj5F_SXDJWRRowT8fhnvAh1tvN4Z2ziNENiPd8FjxGXXGCYaXEfrjFHQ8iK1ieHX6wRfDn8ow9yporeVp5uPj9shYIjdEXaNT37gwQHO6QS_-/s320/homescreen.jpg" /></a></div><ul><li>Start "Settings"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxhTuXS2bXRiMl9dLeSnNrwajRwyy4f0r1L4BCItsUWH0GxSEY9R00JwQNLefV92kFqPdhGy0MK4HqWxUERaH384MxR4T-DbQOTl4BGcxPXck2_Wf9wZMnIbfU9zHryX5x2iITo-ufQ7eL/s1600-h/launcher.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxhTuXS2bXRiMl9dLeSnNrwajRwyy4f0r1L4BCItsUWH0GxSEY9R00JwQNLefV92kFqPdhGy0MK4HqWxUERaH384MxR4T-DbQOTl4BGcxPXck2_Wf9wZMnIbfU9zHryX5x2iITo-ufQ7eL/s320/launcher.jpg" /></a></div><ul><li> Select "Applications"<br />
</li>
<li>Select "Development"</li>
<li>Check "USB debugging" if it's not already checked. <br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ngIdg9jeQdl0ml7OTQUbH_gE1LAjNKnHD-S0ap2s5UnCSho_4RoyRtpfdtes-5eK1CtkxDZ0b59x1wWjMGLSZYf1oBCSlI42O8kfy-IuFX9W7jhL37toCG04n-lm0k7lCqS-XaHyc4LF/s1600-h/USB-debugging.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4ngIdg9jeQdl0ml7OTQUbH_gE1LAjNKnHD-S0ap2s5UnCSho_4RoyRtpfdtes-5eK1CtkxDZ0b59x1wWjMGLSZYf1oBCSlI42O8kfy-IuFX9W7jhL37toCG04n-lm0k7lCqS-XaHyc4LF/s320/USB-debugging.jpg" /></a></div><ul><li> Now that your Nexus One is ready, plug your phone into the computer via the USB cable. If your device drivers are not installed properly check my previous <a href="http://androidcodemonkey.blogspot.com/2010/01/how-to-setup-android-development_23.html">post here (How to Setup Android Development Environment)</a>.<br />
</li>
</ul> Step 4: Launch the Dalvik Debug Monitor<br />
<ul><li>Go to your Android SDK folder > "Tools". On my system I placed the Android SDK here "C:\Program Files\eclipse\android-sdk-windows" so I will navigate to "C:\Program Files\eclipse\android-sdk-windows\tools"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuL6A9C_K1WjENoxG13GGGNoV2olTiZisq4XR130yqSdO6GuAsmLpipUpvBp-dmiVLHtXmOzeWLMj-eQVZI6NKdZ2PUaDp6sJ1mTOqxNx0XRu9QKRxH-jHXHg7KdxuLFnpO737MSvE5Wjo/s1600-h/ddms.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuL6A9C_K1WjENoxG13GGGNoV2olTiZisq4XR130yqSdO6GuAsmLpipUpvBp-dmiVLHtXmOzeWLMj-eQVZI6NKdZ2PUaDp6sJ1mTOqxNx0XRu9QKRxH-jHXHg7KdxuLFnpO737MSvE5Wjo/s320/ddms.PNG" /></a> </div><ul><li> Double click on "ddms.bat" to launch the Dalvik Debug Monitor.</li>
</ul><br />
<div style="color: red;"><b>NOTE: IF IT FAILS TO LOAD </b>and the window just closes immediately, you might have to update your system Environment path for JAVA.</div><ul style="color: red;"><li>If it did not launch go to "Control Panel > System > Advanced system settings"</li>
<li>Press "Environment Variables..."</li>
</ul><div class="separator" style="clear: both; color: red; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlKQGNoHcks-_P4EYFim8bckjPwKEdJBhDkQHxFK4CM1LmIjRKs3wrh0vXe-10yhJAVnN0V8J7EyIZy5hz0B__PTiSVZmp3qL8cjt49xuIRGs-1cuMH4njlWWUJZqYbTVkilOj4-hq41P-/s1600-h/env-var.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlKQGNoHcks-_P4EYFim8bckjPwKEdJBhDkQHxFK4CM1LmIjRKs3wrh0vXe-10yhJAVnN0V8J7EyIZy5hz0B__PTiSVZmp3qL8cjt49xuIRGs-1cuMH4njlWWUJZqYbTVkilOj4-hq41P-/s320/env-var.PNG" /></a></div><ul style="color: red;"><li>Select "Path"</li>
<li>Press "Edit..."</li>
</ul><div class="separator" style="clear: both; color: red; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE1wOGKpd8yN3Hn1RRFi3bwNLy4cNre1lOtFEdEIkKNI0AMBbMKYHOqFWdeX-21km3H1JxvlnmY51tHR4M5ZieKpfmC_NQA4JV41LhSc_mwoUYMBJJd6f1BCsmwlTWCYdGWfcWHXtDcdYX/s1600-h/env-var2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE1wOGKpd8yN3Hn1RRFi3bwNLy4cNre1lOtFEdEIkKNI0AMBbMKYHOqFWdeX-21km3H1JxvlnmY51tHR4M5ZieKpfmC_NQA4JV41LhSc_mwoUYMBJJd6f1BCsmwlTWCYdGWfcWHXtDcdYX/s320/env-var2.PNG" /></a></div><ul style="color: red;"><li> Add the path the path to JAVA (;C:\Program Files\Java\jdk1.6.0_17\bin) to the end of the "variable value"</li>
</ul><div class="separator" style="clear: both; color: red; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_Nl8EackaW-P4aFQkuhduJJaNJWnbRqf_Z_Qj1NIimF5cnSTF3F0rLDZd7PopPajFcDxfdsQ1WFBE9uvh6vbQ1JtFDdAPT2lKSfvTLv9xII-QK8IqJH_4z61w_sE1PzyExtdqHO6OV90N/s1600-h/env-var3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_Nl8EackaW-P4aFQkuhduJJaNJWnbRqf_Z_Qj1NIimF5cnSTF3F0rLDZd7PopPajFcDxfdsQ1WFBE9uvh6vbQ1JtFDdAPT2lKSfvTLv9xII-QK8IqJH_4z61w_sE1PzyExtdqHO6OV90N/s320/env-var3.PNG" /></a></div><ul><li style="color: red;">Press OK and save your changes.</li>
<li>Continue by double clicking on "ddms.bat" to launch the Dalvik Debug Monitor in the "tools" directory. </li>
<li>The application will launch and your phone will be listed.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggDUdLpjJwCecIlI_5uRuQFqvvagNc_vKG74pBO_dhmSGxrzS0UY-q4mQVSj0WMXYKCVN5_uwCGCx3EeyRP9bJ_FAs7XOrXT_T8kr92PAvpZ7jba4iWYN_GCocFpODFJt_6wUd5XPgXgS6/s1600-h/ddms2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggDUdLpjJwCecIlI_5uRuQFqvvagNc_vKG74pBO_dhmSGxrzS0UY-q4mQVSj0WMXYKCVN5_uwCGCx3EeyRP9bJ_FAs7XOrXT_T8kr92PAvpZ7jba4iWYN_GCocFpODFJt_6wUd5XPgXgS6/s320/ddms2.PNG" /></a></div><ul><li> Select "Device > Screen capture..."</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn17USIwcFS9NyYEStzXxepJu5i3vO2hS4_S49Bls5vJRb9IY4HeUc1_3Y8pjwF-s03OMKiz_cFbrUOF19i09njrxzAxW6cWOFRleDgW4y5BzTTk6ddhXLDfImhDwMYSoKD4KI5jlxtBH3/s1600-h/dalvik-debug-monitor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn17USIwcFS9NyYEStzXxepJu5i3vO2hS4_S49Bls5vJRb9IY4HeUc1_3Y8pjwF-s03OMKiz_cFbrUOF19i09njrxzAxW6cWOFRleDgW4y5BzTTk6ddhXLDfImhDwMYSoKD4KI5jlxtBH3/s320/dalvik-debug-monitor.jpg" /></a></div><ul><li>The capture appears.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDncgnJlJvbpBHcOX5DiMpAcisjmrPm8955QZLGs76rEtwuTHEfRglIz0gHzCRwbUynMfqFlRhD1EneO16A6yTmRkLmqx-QBwBDqOZIWJ45CBy0j25cm-av-COzy-moDvGPgvAxkMX4XiG/s1600-h/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDncgnJlJvbpBHcOX5DiMpAcisjmrPm8955QZLGs76rEtwuTHEfRglIz0gHzCRwbUynMfqFlRhD1EneO16A6yTmRkLmqx-QBwBDqOZIWJ45CBy0j25cm-av-COzy-moDvGPgvAxkMX4XiG/s320/Capture.PNG" /></a></div><ul><li> Now you can copy and paste the screen capture into a photo application or save a copy.<br />
</li>
</ul>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com2tag:blogger.com,1999:blog-6158039503477645699.post-45485113417795396582010-01-23T16:35:00.001-07:002010-03-14T10:08:47.675-06:00How to Setup Android Development EnvironmentThere are many ways to develop for Android and because of all the options it is sometimes a little daunting getting your environment setup. I found myself bouncing from web page to web page, not really sure if I had the right tools and if they were setup correctly. I wanted to document the process that worked for me. <br />
<br />
<b>Goal:</b> Step by step instructions to install and configure your Android development environment for Windows.<br />
<br />
<b>Environment/tools: </b>Here is the setup I have chosen to use. <br />
<ul><li>Windows (I'm using Windows 7, but any flavor of windows will do)</li>
<li>Eclipse IDE for Java Developers<i> (v3.5 Galileo) </i></li>
<li>Java Platform <i>(JDK 6 Update 18)</i><br />
</li>
<li> Android SDK Tools, Revision 4</li>
</ul><b> Step 1. Install Eclipse IDE</b><br />
I chose to use the Eclipse IDE for Java Developers (v3.5 Galileo). You can download the it here <br />
<ul><li>Download "Eclipse IDE for Java Developers (92 MB)" from here <a href="http://www.eclipse.org/downloads/"> http://www.eclipse.org/downloads/</a></li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0VsQlxvQs-Mo5m9RFJedMhe07suEvcfXDxYWdbm34qoJywxlmsCTjCvQX0hYMXIGDzZQYeJ5bLJ3ux9b8mjGJ6zbbR7hmRK_P2A2j0wRR7VqKxN00es7F9GhSw99_EDGVXPQom9syaa7S/s1600-h/Eclipse+download.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0VsQlxvQs-Mo5m9RFJedMhe07suEvcfXDxYWdbm34qoJywxlmsCTjCvQX0hYMXIGDzZQYeJ5bLJ3ux9b8mjGJ6zbbR7hmRK_P2A2j0wRR7VqKxN00es7F9GhSw99_EDGVXPQom9syaa7S/s320/Eclipse+download.PNG" /></a></div><ul><li> This is a zip file and does not require installation. Just copy the eclipse folder into your programs directory</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh33nItRq5vwkJ2eMFbm6l0qsgyiuEifuOnc0Yj9A70FVVgIIIdRi50SxvVY51OGUEqbcaQVpLDZtxti1EQuvDKTdBrbm9wPJVTWovucAA7gTpmEOtWqenpjSJ9QVwGxUh5x6i8xKcHxYGw/s1600-h/copy+eclipse.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh33nItRq5vwkJ2eMFbm6l0qsgyiuEifuOnc0Yj9A70FVVgIIIdRi50SxvVY51OGUEqbcaQVpLDZtxti1EQuvDKTdBrbm9wPJVTWovucAA7gTpmEOtWqenpjSJ9QVwGxUh5x6i8xKcHxYGw/s320/copy+eclipse.PNG" /></a></div><b>Step 2: Install Java Platform <i>(JDK 6 Update 18)</i></b><br />
<ul><li> Download the installation file from Sun from here <a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a> </li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwAVSZXD4S5g7FS_Il6GZVMDBv1pqjoli-XFEAq37DyCDf-ibVzmJWs-moqxC3KvgiXzCsIrN_1zusjrw5kEGs3CrS25w586pi7HfbiIpv-K_iFMemL9IKKrlFTc15fa44b3kRVhhP-wXF/s1600-h/Download+JDK.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwAVSZXD4S5g7FS_Il6GZVMDBv1pqjoli-XFEAq37DyCDf-ibVzmJWs-moqxC3KvgiXzCsIrN_1zusjrw5kEGs3CrS25w586pi7HfbiIpv-K_iFMemL9IKKrlFTc15fa44b3kRVhhP-wXF/s320/Download+JDK.PNG" /></a></div><ul><li>Select your platform</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnJ4ubLKsxPhcIS4RocXnlPHcSmCVysOgb5nUb1CcX8fluAHZf_ttZW4EzDb6iOwRUBjjB_i5RZlqpnjo2Qbq6_aN4VG2jqVIy12d-YC3tIswcTK3b5ENg14biRGowvGQW8hmOh5tCN19r/s1600-h/Download+JDK-2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnJ4ubLKsxPhcIS4RocXnlPHcSmCVysOgb5nUb1CcX8fluAHZf_ttZW4EzDb6iOwRUBjjB_i5RZlqpnjo2Qbq6_aN4VG2jqVIy12d-YC3tIswcTK3b5ENg14biRGowvGQW8hmOh5tCN19r/s320/Download+JDK-2.PNG" /></a></div><br />
<ul><li>Now run the JDK installation. I did not change any of the default installation options. When complete continue to step 3.<br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggxWYzwIsFrL_OLSiZgKZnnQry8iQag8atWHFrKBj18JfE4VtRQfSj2Ehx2j80oKnwsWcmz5cebr2wy_YNJBxObM2T7dry1wQvIMwpBfUTg6UqG_iJhyphenhyphenusRPI8vOsuVG-T2y6yUfNzNj0q/s1600-h/jdk3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggxWYzwIsFrL_OLSiZgKZnnQry8iQag8atWHFrKBj18JfE4VtRQfSj2Ehx2j80oKnwsWcmz5cebr2wy_YNJBxObM2T7dry1wQvIMwpBfUTg6UqG_iJhyphenhyphenusRPI8vOsuVG-T2y6yUfNzNj0q/s320/jdk3.PNG" /></a></div><br />
<br />
<b>Step 3: Download the Android SDK Tools, Revision 4</b><br />
<ul><li>Download the install package "<a href="http://developer.android.com/sdk/download.html?v=android-sdk_r04-windows.zip">android-sdk_r04-windows.zip</a>" from here <a href="http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html</a> </li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVwbSZgHflBaJV_68K2YLRGmeeuMvLP7sKzw9tasxun2QGQwHmnp06-h4LwrlWu-TYnpA-XZCDK58JcrL45smoTkx4swtK_wfGfpLCRK-9HmYyIxqDXMys9dMrh1jVQt3uAPuSBz-i0GBz/s1600-h/android+sdk1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVwbSZgHflBaJV_68K2YLRGmeeuMvLP7sKzw9tasxun2QGQwHmnp06-h4LwrlWu-TYnpA-XZCDK58JcrL45smoTkx4swtK_wfGfpLCRK-9HmYyIxqDXMys9dMrh1jVQt3uAPuSBz-i0GBz/s320/android+sdk1.PNG" /></a></div><br />
<ul><li>This does not require installation. Just unzip and copy the files. You can install the package anywhere but remember where you put as you will need to reference it in Eclipse. I happen to install it inside my eclipse folder.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6TVacProK3CqzP0Gnw6AwFr7-W6kJdYrG766y5gRLWRd-0G9-WHT59fY_X3_AnLm58wSpryeY_SpUWw5W4_xdxXSC2F0c-mCA0RtewT5Z7ou0I3BKTPXQs-gywQmyRUHEInpHQ7v20UnD/s1600-h/android+sdk2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6TVacProK3CqzP0Gnw6AwFr7-W6kJdYrG766y5gRLWRd-0G9-WHT59fY_X3_AnLm58wSpryeY_SpUWw5W4_xdxXSC2F0c-mCA0RtewT5Z7ou0I3BKTPXQs-gywQmyRUHEInpHQ7v20UnD/s320/android+sdk2.PNG" /></a></div><br />
<b>Step 4: Configure Android SDK<br />
</b><br />
<i></i><br />
<ul><li>Launch "SDK-Setup.exe" located in the Android SDK install folder"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbGeR7oV1Dtl4MFGAKL-ZAw5or7HGbDVz0t-xMMBYI1xQmFA3VEjBgVT6kFMfJJ2HKSxiCeEHUO2wHTF7NIK_fynsNZg2PNsd4FFObrA9vut4OOE8OF4v7FxQ0pc0jg00O9dDIJ1DXwWZw/s1600-h/sdk1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbGeR7oV1Dtl4MFGAKL-ZAw5or7HGbDVz0t-xMMBYI1xQmFA3VEjBgVT6kFMfJJ2HKSxiCeEHUO2wHTF7NIK_fynsNZg2PNsd4FFObrA9vut4OOE8OF4v7FxQ0pc0jg00O9dDIJ1DXwWZw/s320/sdk1.PNG" /></a></div><ul><li> If you receive the following "Failed to fetch url https://dl-ssl.google.com/android/repository/repository.xml" we need to change the URL to not use SSL. Close the error dialog.<br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwc1YCC1xYmr7wQhFid1HdZpSAdw-OmkH24ZBg-OustgY3dzj1sSmJhSzHtSTpYgDtMrPLCHTnYq8rgXw1_-_ZBbfXcp9NN1vc5HVrz5FibsXkz6TzmwCD1QoTsd4YRoekIxdroDFX4RiX/s1600-h/sdk2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwc1YCC1xYmr7wQhFid1HdZpSAdw-OmkH24ZBg-OustgY3dzj1sSmJhSzHtSTpYgDtMrPLCHTnYq8rgXw1_-_ZBbfXcp9NN1vc5HVrz5FibsXkz6TzmwCD1QoTsd4YRoekIxdroDFX4RiX/s320/sdk2.PNG" /></a></div><ul><li>Press "Cancel" on the "Choose Packages to Install" Dialog<br />
</li>
</ul><ul><li>Select "Settings" in the left pane</li>
<li>Check "Force https://... sources to be fetched using http://"</li>
<li>Press "Save and Apply"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwpO5NcKdfcBa-FT6tKQ1Lq-k02ZKaWDJk_y4DFdcaVIumuuWiJ_KXHZMoWftmSZrUSOnkXuFmRyiF3R4DZ6uPP9YqlCukaeqrS4xTHz5vRfMuC6nfKqOwabTjCJ8S6hakXP-_cMgpg5z/s1600-h/sdk3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwpO5NcKdfcBa-FT6tKQ1Lq-k02ZKaWDJk_y4DFdcaVIumuuWiJ_KXHZMoWftmSZrUSOnkXuFmRyiF3R4DZ6uPP9YqlCukaeqrS4xTHz5vRfMuC6nfKqOwabTjCJ8S6hakXP-_cMgpg5z/s320/sdk3.PNG" /></a></div><ul><li>Select "Available Packages" in the left pane</li>
<li>Select "Documentation" <i>(at the top of the list)</i><br />
</li>
<li>Select "Usb Driver Package, rev 3 <i>(at the bottom of the list)</i></li>
<li>And then select any platform you want to develop. You can select all (be prepared for a long download) or you can select only the platfrom for you phone. The Nexus One uses 2.1 and the Droid for Verizon uses 2.0.1.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqwwwxObRt0SxtJqGTFTN8BgVUNbrirwkqQLxuDmF11_sP9Zb4pmS2SKxpHsydIHAUEQ9FqB8suvlulS5t3OTispxcyCuzYYdgpcOhshT7f27DKdSlYruflFWQmKrWC6_-CTBPhVh9788e/s1600-h/sdk4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqwwwxObRt0SxtJqGTFTN8BgVUNbrirwkqQLxuDmF11_sP9Zb4pmS2SKxpHsydIHAUEQ9FqB8suvlulS5t3OTispxcyCuzYYdgpcOhshT7f27DKdSlYruflFWQmKrWC6_-CTBPhVh9788e/s320/sdk4.PNG" /></a></div><ul><li> Check "Accept All" and Press "Install Accepted"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh08KreKUnHAhchuLuAWnraZDP5tVgLREeamSq7NDDKpiLOe8sMsi82UemHSvZSUuYtHj8XaVGrHoHLQFrTSoyAZAGjH9okFE6Eoz-DFbycEPDhBCMdr_QldLrbj_WK8mX6Zt44gQXWz3Me/s1600-h/sdk5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh08KreKUnHAhchuLuAWnraZDP5tVgLREeamSq7NDDKpiLOe8sMsi82UemHSvZSUuYtHj8XaVGrHoHLQFrTSoyAZAGjH9okFE6Eoz-DFbycEPDhBCMdr_QldLrbj_WK8mX6Zt44gQXWz3Me/s320/sdk5.PNG" /></a></div><br />
<ul><li>When done press "Close"<br />
</li>
<li>Now we are going to create a virtual device (AVD) </li>
<li>Select "Virtual Devices" in the left pane<br />
</li>
<li>Select "New..."</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga1mh4zap23BOiGOFlnDG4SlV1YKQvGAgRsyIwCSHb5aWpIKqhSNh326Xjd14QmP3y8C9NBeIUnEEg4pCwVUCWx7c2xSZYDtIwed9M8foFyMkZ7d23eD-mAmGowQs4oj5eIh4fp1q7UueS/s1600-h/avd1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga1mh4zap23BOiGOFlnDG4SlV1YKQvGAgRsyIwCSHb5aWpIKqhSNh326Xjd14QmP3y8C9NBeIUnEEg4pCwVUCWx7c2xSZYDtIwed9M8foFyMkZ7d23eD-mAmGowQs4oj5eIh4fp1q7UueS/s320/avd1.PNG" /></a></div><ul><li> Create the following new Android Virtual Device</li>
<ul><li><b>Name: </b>Android2.1 <br />
</li>
<li><b>Target: </b>Android 2.1 API Level 7 <i>(Or which ever API you installed)</i><br />
</li>
<li><b>SD card Size: </b>4000 MiB to 32000MiB (16000 MiB shown)<br />
</li>
<li>Leave the rest at the default settings</li>
</ul></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTeFjrEtFqE8t4cUTDRcL05H6c3vuiZwUz8yEHENF_JJlFsYfVeH4E-vpLeBilxSC_CiVRvDUf7OPx-MOaa2XadifvRoiqADXhzYhg6UxvuqzzkZ_KGfFuodgrVBm5Ah8mY1pzlHgtgRDJ/s1600-h/AVDdetails.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTeFjrEtFqE8t4cUTDRcL05H6c3vuiZwUz8yEHENF_JJlFsYfVeH4E-vpLeBilxSC_CiVRvDUf7OPx-MOaa2XadifvRoiqADXhzYhg6UxvuqzzkZ_KGfFuodgrVBm5Ah8mY1pzlHgtgRDJ/s320/AVDdetails.PNG" /></a></div><br />
<ul><li>Press "Create AVD". Be patient it may take a few minutes to create your new AVD.</li>
<li>Close the SDK setup. </li>
</ul><b>Step 5: Configure Eclipse</b><br />
<i>(These instructions are for Galileo version of Eclipse. Please see this <a href="http://developer.android.com/sdk/eclipse-adt.html">page</a> for instructions if you downloaded the Ganymede </i><i>version of Eclipse)</i><b><br />
</b><br />
<ul><li>Launch Eclipse for the first time. You will be asked where you want to your workspace folder to be located. </li>
<ul><li>I used the default location. </li>
<li>Check "Use this as the default and do not ask again" so you don't have to answer this question every time. <br />
</li>
<li>Press "OK".<br />
</li>
</ul></ul><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgps3TMOFl-T-z6llLNbuIyhyEN_R8NNq9EMWulD5THtWNjq5NxCrqDZV7bmGa7RgEjEJLyI_ua-a4-sBx03kEzpWBXTkEW0PxYWb1z4EhQB6p-mxMnVC5qDryplE2zmvS7_8klosG-ATi9/s1600-h/eclipse1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgps3TMOFl-T-z6llLNbuIyhyEN_R8NNq9EMWulD5THtWNjq5NxCrqDZV7bmGa7RgEjEJLyI_ua-a4-sBx03kEzpWBXTkEW0PxYWb1z4EhQB6p-mxMnVC5qDryplE2zmvS7_8klosG-ATi9/s320/eclipse1.PNG" /></a></div><ul><li>Select <b>"Help > Install New Software..."</b></li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfhcXKJlSLYdBkXp6uSzcbSjy1fmQdrsXgZQPjB-WzVGVANzAFxqCHXl_G_yw1BX_pmmoGdeEsJrvxv2B5cIJRmQd53WNKN2uxDuCebuZUgSFaY0Oqof2yF86Tqe0-PdZBhzUcVztGukE/s1600-h/eclipse2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfhcXKJlSLYdBkXp6uSzcbSjy1fmQdrsXgZQPjB-WzVGVANzAFxqCHXl_G_yw1BX_pmmoGdeEsJrvxv2B5cIJRmQd53WNKN2uxDuCebuZUgSFaY0Oqof2yF86Tqe0-PdZBhzUcVztGukE/s320/eclipse2.PNG" /></a></div><ul><li> Press "Add..."</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSBMCQQHCRSx2CLpb8njGHP9ScU0rXp5iucqCM4JtZvLGpo91dv7zi3QFTF2pEgC4toA0de2_10vE_tKa8QF60W48JoTMboqEG4WRf49CvHRYFe1AqhhFYOiQcQGUSSITvvr_iNqlHlb4Q/s1600-h/eclipse2.5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSBMCQQHCRSx2CLpb8njGHP9ScU0rXp5iucqCM4JtZvLGpo91dv7zi3QFTF2pEgC4toA0de2_10vE_tKa8QF60W48JoTMboqEG4WRf49CvHRYFe1AqhhFYOiQcQGUSSITvvr_iNqlHlb4Q/s320/eclipse2.5.PNG" /></a></div><ul><li>Fill out the Add Site information<br />
</li>
<ul><li><b>Name: </b>Android<br />
</li>
<li><b>Location: </b>https://dl-ssl.google.com/android/eclipse/</li>
<li>Press "OK"</li>
</ul></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgPyTROFUk0Z4g04SZoQwYLI7kKcU_oE2DZoy6BDWHphhsrzcCev2jlnWh6JPlFZsU6kgWjJgtXBR1lq_gwVWW-zaszzhJAcMtyidlhg8eLtKkv5CCwCkNXjaOLx8BfMTFdcj9mWmgGK9p/s1600-h/eclipse3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgPyTROFUk0Z4g04SZoQwYLI7kKcU_oE2DZoy6BDWHphhsrzcCev2jlnWh6JPlFZsU6kgWjJgtXBR1lq_gwVWW-zaszzhJAcMtyidlhg8eLtKkv5CCwCkNXjaOLx8BfMTFdcj9mWmgGK9p/s320/eclipse3.PNG" /></a></div> If you get an error don't use SSL. change location from "https://dl-ssl.google.com/android/eclipse/" to "http://dl-ssl.google.com/android/eclipse/"<br />
<ul><li> After a connection is made and available tools are retrieved expand "Developer Tools" and select "Android DDMS" and "Android Development Tools"</li>
<li>Press "Next"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3MOkBVZBtJGEUk1mi_3CQ6-rMvD2ZY8sFdouAVMv0KBwp1cDAzDialEv0CGne_YWtQqqsAn6E02yzLFm8WIMqeQFwlKA2w5U-DP9pQH7Iof58Oyh_9m1hvLJwQP-wApPHqtuXwehPAfvQ/s1600-h/eclipse4.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3MOkBVZBtJGEUk1mi_3CQ6-rMvD2ZY8sFdouAVMv0KBwp1cDAzDialEv0CGne_YWtQqqsAn6E02yzLFm8WIMqeQFwlKA2w5U-DP9pQH7Iof58Oyh_9m1hvLJwQP-wApPHqtuXwehPAfvQ/s320/eclipse4.PNG" /></a></div><ul><li> Press "Next" again.</li>
<li>Check "I accept the terms of the license agreements"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXRubIz4IRe1aBQ5E3Z3CZ8Bjr68n7NXjpL2F_VrWUEvrzf-_XK_Xexf4E0f94NZqlthcutnsz_tDCgEe2ph2AnH7kYGJGGgaUoZb9bbp3Ll3hnDucUtJ4lqsGdG9wYPfpcp0Am4m9hF-z/s1600-h/eclipse5.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXRubIz4IRe1aBQ5E3Z3CZ8Bjr68n7NXjpL2F_VrWUEvrzf-_XK_Xexf4E0f94NZqlthcutnsz_tDCgEe2ph2AnH7kYGJGGgaUoZb9bbp3Ll3hnDucUtJ4lqsGdG9wYPfpcp0Am4m9hF-z/s320/eclipse5.PNG" /></a></div><ul><li> You may receive a Security Warning about unsigned content. Press "OK"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2T2cyfF0Ft_F5EqHqW1SsWTDn-a6acQBB1bH_foXsX_UGnCHtOxSZZ8JIz9-tWWc2yIo1apNnuf5axp7NYNdcmhkloJXz7w6XRHY_jFCGSOpFxHNhOEeejJRpacSf8iwHRtqRC8izC95/s1600-h/eclipse6.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2T2cyfF0Ft_F5EqHqW1SsWTDn-a6acQBB1bH_foXsX_UGnCHtOxSZZ8JIz9-tWWc2yIo1apNnuf5axp7NYNdcmhkloJXz7w6XRHY_jFCGSOpFxHNhOEeejJRpacSf8iwHRtqRC8izC95/s320/eclipse6.PNG" /></a></div><ul><li> Done. Now you should restart Eclipse.</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9FkltBYmf_06uMzRDjAV4omyP7ekd1hB3kxubQXSoYyG8EGVnyS8f-L0lkg2j5jzC0Mj9__mXn_ND6m8vdBjDrZ2BPyVGdKnnr9vK21poX_fFQtC-7CkiGa80A3Niu3zy-Kd1Xw8An6BP/s1600-h/eclipse7.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9FkltBYmf_06uMzRDjAV4omyP7ekd1hB3kxubQXSoYyG8EGVnyS8f-L0lkg2j5jzC0Mj9__mXn_ND6m8vdBjDrZ2BPyVGdKnnr9vK21poX_fFQtC-7CkiGa80A3Niu3zy-Kd1Xw8An6BP/s320/eclipse7.PNG" /></a></div><ul><li> After rebooting we need to tell Eclipse where we copied the "Android SDK" in step 3.</li>
<li>Select <b>"Windows > Preferences"</b></li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3ZMn5uMwgrZa60JLxCtNc36Bk2mfvVvYI0B-_eF6jRmC585S9oLCl5ap4rnOkuEYQW5TWGgoXs5NBgkkD6xEYayp2gWKOemKchLstEFSxLBGcUIpGzJGnIcPAoVxot4tGLokPGpdDbfhK/s1600-h/eclipse8.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3ZMn5uMwgrZa60JLxCtNc36Bk2mfvVvYI0B-_eF6jRmC585S9oLCl5ap4rnOkuEYQW5TWGgoXs5NBgkkD6xEYayp2gWKOemKchLstEFSxLBGcUIpGzJGnIcPAoVxot4tGLokPGpdDbfhK/s320/eclipse8.PNG" /></a></div><ul><li> Select "Android" from the left pane. After you select "Android" you will receive an error. That is because it is not setup yet. We are setting it up now.<br />
</li>
<li>For the SDK Location, browse to where you installed the SDK.</li>
<li>Press "OK"<br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEZeaei5I5lZXYW_BXBCGb83fKzAQHNzO3e8LNbVOQLja1Wme3BlABgZFmQFbhyphenhyphennzYJqhqxllCX_DIyw-45wC4hHHEMAlPQDLsS2cdn3Clh1s8cXM8YL3fjyhM85BxIzVazQNw5Hx2pTV1/s1600-h/eclipse9.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEZeaei5I5lZXYW_BXBCGb83fKzAQHNzO3e8LNbVOQLja1Wme3BlABgZFmQFbhyphenhyphennzYJqhqxllCX_DIyw-45wC4hHHEMAlPQDLsS2cdn3Clh1s8cXM8YL3fjyhM85BxIzVazQNw5Hx2pTV1/s320/eclipse9.PNG" /></a></div><ul><li>A dialog box will appear. If you want to send usage data to Google leave it checked, other uncheck it and press "Continue". This dialog box can sometimes get trapped beneath your window. Minimize Eclipse if you don't see it.<br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifAX_3L6EtX5-jn1oy3DgrdUt4E1hcHJgDSouHBFRX6pA-Y31YJo71ryMPcJ4qfpcY5Kl4MvFe-edQ4CPCXD6yGuNVXVDh5MhBRZYNct0sPz-PiUEC1chIgBN-qDf67tO9Yk6JK2pUNpzv/s1600-h/eclipse10.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifAX_3L6EtX5-jn1oy3DgrdUt4E1hcHJgDSouHBFRX6pA-Y31YJo71ryMPcJ4qfpcY5Kl4MvFe-edQ4CPCXD6yGuNVXVDh5MhBRZYNct0sPz-PiUEC1chIgBN-qDf67tO9Yk6JK2pUNpzv/s320/eclipse10.PNG" /></a></div><br />
You are now ready to build your first application. To create a "Hello World" app check out my post <a href="http://androidcodemonkey.blogspot.com/2010/01/hello-world-your-first-android.html">here.</a> If you have any questions feel free to post a comment and I will do my best to answer.<br />
<ul></ul>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com80tag:blogger.com,1999:blog-6158039503477645699.post-5534621068852088312010-01-20T00:15:00.004-07:002011-10-26T07:47:05.998-06:00Hello World - Your First Android ApplicationFollowing is a step by step guide in creating your first "Hello World" Android application.It was created with the following setup:<br />
<ul><li>Windows (I happen to be using Windows 7, but any flavor of windows will do)</li>
<li>Eclipse IDE for Java Developers<i> (v3.5 Galileo) </i></li>
<li>Java Platform <i>(JDK 6 Update 18)</i><br />
</li>
<li> Android SDK Tools, Revision 4</li>
</ul>Let's get started... <br />
<br />
<ul><li>Create a new Android project (File > New > Android Application)</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4d2PSaReBQGM8jXbddwBb-OaV77XkGCi6Uu5vWIf9BAMiW_IC95QjQJbccveAofbGBKZa8GiwEzEhmF_MX7uIBYubHuNHDam54XttJPOyd1F8t_io9p8tdCvhJtT8p1XforVRxDu6avN3/s1600-h/New+Android+App.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4d2PSaReBQGM8jXbddwBb-OaV77XkGCi6Uu5vWIf9BAMiW_IC95QjQJbccveAofbGBKZa8GiwEzEhmF_MX7uIBYubHuNHDam54XttJPOyd1F8t_io9p8tdCvhJtT8p1XforVRxDu6avN3/s320/New+Android+App.PNG" /></a></div><ul><li>Set your project properties</li>
<ul><li><b>Project Name: </b>Hello World</li>
<li><b>Build Target: </b>Select Android 2.1</li>
<li><b>Application Name:</b> Hello World</li>
<li><b>Package Name: </b>com.android.test</li>
<li><b>Create Activity: </b>HelloWorld</li>
</ul><li>Press "Finish"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWYiWGNh34LIor9fLAZteFz_RntVWhgUEv-7n9ey8_sBgdLkZrhOx9nb39RvPoJqZmvWbEMza4ZupmCbpZenibcZOknjzoVnHS-gAKzlFXX276ax61a2J9TEFDdRzLz0OQuo-yrFlurW4E/s1600-h/ProjectProperties.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWYiWGNh34LIor9fLAZteFz_RntVWhgUEv-7n9ey8_sBgdLkZrhOx9nb39RvPoJqZmvWbEMza4ZupmCbpZenibcZOknjzoVnHS-gAKzlFXX276ax61a2J9TEFDdRzLz0OQuo-yrFlurW4E/s320/ProjectProperties.PNG" /></a></div><br />
Now you have your project created let's write some code! Your code is located in a file called HelloWorld.java in the src folder. Your screen layout file is main.xml in the layout directory.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGs4OyXKTPxT0agUvxK1zaFZyP69fpOZnlcVTf3Zu8_k13MNQJ2oVb9HilObprr4plG1Ez6hG3jBcTBpg0-FNPvoXE9M4CZqsp_-Xk8W-_UTdFOgefo1hnyhwpiacDfozob6CELusH57MV/s1600-h/ProjectFiles.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGs4OyXKTPxT0agUvxK1zaFZyP69fpOZnlcVTf3Zu8_k13MNQJ2oVb9HilObprr4plG1Ez6hG3jBcTBpg0-FNPvoXE9M4CZqsp_-Xk8W-_UTdFOgefo1hnyhwpiacDfozob6CELusH57MV/s320/ProjectFiles.PNG" /></a></div>Let's take a look at the main.xml (layout) file. Open main.xml. You should now see it in "Layout" mode like this...<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBL1N3RpP-Zid3SOgemsw5IbXBbNDBYRUT_dbyKhKYTdKYGxQs2oXG1JJh_zLJOWzhnw4x_rIS7CbN8aFEbfZaS6hKkcshZnzTKo_lATX6raMe0ey2am7LofttCjNUqwp3cPVmn2JsoOsB/s1600-h/main.xml.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBL1N3RpP-Zid3SOgemsw5IbXBbNDBYRUT_dbyKhKYTdKYGxQs2oXG1JJh_zLJOWzhnw4x_rIS7CbN8aFEbfZaS6hKkcshZnzTKo_lATX6raMe0ey2am7LofttCjNUqwp3cPVmn2JsoOsB/s320/main.xml.png" /></a></div><br />
and if you select "main.xml" you can view/edit the xml markup<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrLS4naCYtJ3scxuCHK_zDyBN0sdh0Qt6pbwCnKDIhepTrWR75Re8hZ94CyYjLINR9S1X9n7hIMa1rI-2myNlVvghcZuVxQ4XsziWVFJQQdk_N1vs_UImWnG8e-vaoK6N4TpHaQ71wB8kb/s1600-h/main.xml.XML.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrLS4naCYtJ3scxuCHK_zDyBN0sdh0Qt6pbwCnKDIhepTrWR75Re8hZ94CyYjLINR9S1X9n7hIMa1rI-2myNlVvghcZuVxQ4XsziWVFJQQdk_N1vs_UImWnG8e-vaoK6N4TpHaQ71wB8kb/s320/main.xml.XML.png" /></a></div>Let's remove the default textview to cleanup our display<br />
<ul><li>Return to "Layout" mode</li>
<li>Right click on "Hellow World, HelloWorld!" TextView and select "Remove"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9TWLyEJtZas18B4zAFz6_3ZQMQ-NGcTUKXwJELPBrsN8fY6l2u_7qaDnSqNDfFIzrxuZ6Q5yfHGpSvVosY-2BsVw0HaSJXheg4LyBGRDpqPBSX45jklUUDyDWlWuUB_9dtubId_JZW8W_/s1600-h/remove+default+textview.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9TWLyEJtZas18B4zAFz6_3ZQMQ-NGcTUKXwJELPBrsN8fY6l2u_7qaDnSqNDfFIzrxuZ6Q5yfHGpSvVosY-2BsVw0HaSJXheg4LyBGRDpqPBSX45jklUUDyDWlWuUB_9dtubId_JZW8W_/s320/remove+default+textview.PNG" /></a></div>Drag a button on to layout<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyID7wVqA1Mp5YppFgfjNHvww_BmaShrh_IbAakwso2ZcQtGNdv7jQjRcmv1r0f9mjaEPuzqNeKpxAj3SxTJf-niSkZXnqcwKLQBx4SnBF3gvH7-ZbO91_fHM4NeDw88GA-ZTIYPS4Zdba/s1600-h/DragButton.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyID7wVqA1Mp5YppFgfjNHvww_BmaShrh_IbAakwso2ZcQtGNdv7jQjRcmv1r0f9mjaEPuzqNeKpxAj3SxTJf-niSkZXnqcwKLQBx4SnBF3gvH7-ZbO91_fHM4NeDw88GA-ZTIYPS4Zdba/s320/DragButton.PNG" /></a></div>View/edit the XML by clicking on "main.xml" <br />
<ul><li>Change android:text="@+id/Button01" to android:text="Click Me"</li>
<li>Save your changes <br />
</li>
</ul>Your main.xml file now is complete and should look like this<br />
<pre class="brush: xml; "><?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"
>
<button android:text="Click Me" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
</pre>Now we have a button let's make something happen when the button is pressed.<br />
<ul><li>Open "HelloWorld.java" file. There is already code for when the class is created that set's the content view.</li>
</ul><pre class="brush: java; ">@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
</pre><ul><li>Add the highlighted code on line #5. Create a button object and reference the button we placed on our layout. After you add the following line of code you will get an error. This is because you need to import "android.widget.Button". The fastest way to import is the hotkey Ctrl-SHIFT-O. This will add all missing imports.<br />
</li>
</ul><pre class="brush: java; highlight: 5; ">@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.Button01);
}
</pre><ul><li>Register a callback to be invoked when this button is clicked. Add the highlighted code in lines #6-#10. </li>
</ul><pre class="brush: java; highlight: [6,7,8,9,10] ">@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
</pre><ul><li>Now let's add some code in the method "OnClick" to pop up a message when the button is clicked. Add the highlighted code on line #9.</li>
</ul><pre class="brush: java; highlight: 9; ">@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(HelloWorld.this, "Hello World", Toast.LENGTH_SHORT).show();
}
});
}
</pre><br />
Now let's run our new application.<br />
<ul><li>Select "Run > Run"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5cDxbaO5eVPfMAobizBLyTAHIaSvuJzfTDj3r1CFQxnH6YPF_nIPfmK0WdaqIDB1buXzWkxjqSek3pQpqATFgFmYpOtE_TI6WuSefdAPWWCt6ddW7N4f3MPXO34VrVxtEvxBUp1JdOYav/s1600-h/Run.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5cDxbaO5eVPfMAobizBLyTAHIaSvuJzfTDj3r1CFQxnH6YPF_nIPfmK0WdaqIDB1buXzWkxjqSek3pQpqATFgFmYpOtE_TI6WuSefdAPWWCt6ddW7N4f3MPXO34VrVxtEvxBUp1JdOYav/s320/Run.PNG" /></a></div><ul><li>You will get a dialog "Run As". Select "Android Application"<br />
</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjERDx6NZ-2wgKXKo7rC4rPdSSyqemkYqljulMjulj_xNrz1qRM5x07IcwmTFJu1GBknzHW-tVOKgsxCyIr7ucJvfySZkZo_ECmehL7I1fb55C49dj1lncbJjEFVwVM_D_u-TI68YhNXNj8/s1600-h/RunAs.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjERDx6NZ-2wgKXKo7rC4rPdSSyqemkYqljulMjulj_xNrz1qRM5x07IcwmTFJu1GBknzHW-tVOKgsxCyIr7ucJvfySZkZo_ECmehL7I1fb55C49dj1lncbJjEFVwVM_D_u-TI68YhNXNj8/s320/RunAs.PNG" /></a></div><blockquote>You may receive "Android AVD Error" if you have not setup an android emulator device.</blockquote><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqrnmsc7GDYqaATCa_auK7YkCXethflymy9deFWywFVMz733JAbcfjOLPr_EQw9t4sm3yv5LeLyCHC9AHUMZxv3U06TG3QXI5WZiOytUMo98yYJtFDo8yYspqGeirM9rEJsEMiKdkIRJB8/s1600-h/NoAVD.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqrnmsc7GDYqaATCa_auK7YkCXethflymy9deFWywFVMz733JAbcfjOLPr_EQw9t4sm3yv5LeLyCHC9AHUMZxv3U06TG3QXI5WZiOytUMo98yYJtFDo8yYspqGeirM9rEJsEMiKdkIRJB8/s320/NoAVD.PNG" /></a></div><ul><li>Select yes to setup a new Android Virtual Device</li>
<li>Select "New"</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDAAYUXJkF3ybOqxmxB97uLlWveDvla31ZAH311-d5uO27qaPVYm9b5FgHWDssbVt1aEASm2iT0-lEsiD-pvKvZJAQ2zOokc-EdayiESrqKxlA5s9Uh0WFSmdMHISmM8-W5vM95Zh4DcbV/s1600-h/newAVD.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDAAYUXJkF3ybOqxmxB97uLlWveDvla31ZAH311-d5uO27qaPVYm9b5FgHWDssbVt1aEASm2iT0-lEsiD-pvKvZJAQ2zOokc-EdayiESrqKxlA5s9Uh0WFSmdMHISmM8-W5vM95Zh4DcbV/s320/newAVD.PNG" /></a></div><ul><li> Create the following new Android Virtual Device</li>
<ul><li>Name: Android2.1</li>
<li>Target: Android 2.1 API Level 7</li>
<li>SD card Size: 4000 MiB</li>
<li>Leave the rest at the default settings</li>
</ul></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTeFjrEtFqE8t4cUTDRcL05H6c3vuiZwUz8yEHENF_JJlFsYfVeH4E-vpLeBilxSC_CiVRvDUf7OPx-MOaa2XadifvRoiqADXhzYhg6UxvuqzzkZ_KGfFuodgrVBm5Ah8mY1pzlHgtgRDJ/s1600-h/AVDdetails.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTeFjrEtFqE8t4cUTDRcL05H6c3vuiZwUz8yEHENF_JJlFsYfVeH4E-vpLeBilxSC_CiVRvDUf7OPx-MOaa2XadifvRoiqADXhzYhg6UxvuqzzkZ_KGfFuodgrVBm5Ah8mY1pzlHgtgRDJ/s320/AVDdetails.PNG" /></a></div><br />
<ul><li>Press "Create AVD". Be patient it will take a minute to create your new AVD.</li>
<li>Select your new AVD and run your application.</li>
</ul>When you click the button you should see the following<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwTirKsvE-4qtcsHpdl58D2VBFKcmQwPohNbz4OCX9SnZb35RmODFW10DapHritMn5tO_dEkGXpNyAPa0vl4i3u16H0Zs3Uvez1Tc-_KakCVfPwg9oTYRPpE6e7IWrHUVBtS0ehE_ZbqBo/s1600-h/avd.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwTirKsvE-4qtcsHpdl58D2VBFKcmQwPohNbz4OCX9SnZb35RmODFW10DapHritMn5tO_dEkGXpNyAPa0vl4i3u16H0Zs3Uvez1Tc-_KakCVfPwg9oTYRPpE6e7IWrHUVBtS0ehE_ZbqBo/s320/avd.PNG" /></a> </div>NOTE: If you receive an error try the following:<br />
<ul><li>Try removing "@Override" on line 18.</li>
<li>change line 15 from "setContentView(R.layout.main);" to "this.setContentView(R.layout.main);"</li>
</ul><br />
<u><b>Complete source for project</b></u><br />
<b>HelloWorld.java</b><br />
<pre class="brush: java; ">package com.android.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(HelloWorld.this, "Hello World", Toast.LENGTH_SHORT).show();
}
});
}
}
</pre><br />
<br />
<b>main.xml</b><br />
<pre class="brush: xml; "><?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"
>
<button android:text="Click Me"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>
</pre><br />
Download the complete project<br />
<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://cid-369caadcbdc49509.office.live.com/embedicon.aspx/Blog%20Files/Hello%20World.zip" style="background-color: #fcfcfc; height: 115px; padding: 0; width: 98px;" title="Preview"></iframe><br />
<br />
If you import the project and receive a <b>Must Override a Superclass Method Error</b>, your targeting the wrong JDK version. Go to my blog post to resolve this error. <a href="http://androidcodemonkey.blogspot.com/2011/10/how-to-solve-must-override-superclass.html">http://androidcodemonkey.blogspot.com/2011/10/how-to-solve-must-override-superclass.html</a><br />
<br />
Please feel free to post comments or questions. I will do my best to answer your questions.<br />
<ul></ul>Anonymoushttp://www.blogger.com/profile/07134696274167785494noreply@blogger.com113