Thursday, 30 September 2010

iPad Tethering a Possibility

iPhone iPad pictureIt appears that iPad tethering could be a possibility in the next iOS update. Now this is a sweet idea. With the log battery life of an iPad, this would be really useful. I hope this rumor turns out to be true!

Arduino Bots and Gadgets




Make: Arduino Bots And Gadgets

Want to build your own robots, turn your ideas into prototypes, control devices with a computer, or make your own cell phone applications? It�s a snap with this book and the Arduino single-board microcontroller. Embedded systems are everywhere -- inside washing machines, cars, vacuum cleaners, and air conditioners. With Arduino, building your own embedded gadgets is easy, even for beginners.

This book gets you started with six fun projects: a stalker guard, robot insect, interactive painting, wireless smart home controller, boxing timer, and a cell phone controlled soccer robot. You�ll get impressive results quickly and gain the know-how and experience you need to invent your own gadgets.

  • Discover Arduino, the popular electronic prototyping platform
  • Get a great introduction to robots and electronic projects
  • Learn how to turn ideas into working physical prototypes
  • Use Android phones as key components in your projects
  • Get everyone involved with projects that even beginners can build




Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Wednesday, 29 September 2010

TinyUmbrella - AppleTV support

While updating the UI I decided to slip in Apple TV support. This incremental update will allow you to save your SHSH for your shiny new Apple TV. With some amazing things just around the corner, it's very important to save your SHSH to allow you to restore your Apple TV to its initial factory iOS version. Enjoy.

Tuesday, 28 September 2010

No More Web Jobs?

Internet IconNo more web jobs? What?!?!?? It seems a few days ago Smashing Magazine posted this article hailing the end of all Web Design jobs. It seems the articles author thinks in the future, only Facebook, Twitter, and mobile apps will matter. Why would anyone use anything else? :)



Thankfully, Smashing allowed web designer Michael Aleo to post a rebuttal stating why there will be web design jobs for years to come.



So I would like to make a couple of points on the premise of the original article.



First, let me say, don't get caught up in labels. Back in the day, everyone wanted to hire a "webmaster". Well for the most part that job title has gone away, but there are still plenty of jobs. Designer is just one title and if that title goes away, the fundamental skills will always be in demand.



Second, in my opinion, Twitter and Facebook are just better versions of chat clients like AOL Instant Messenger (AIM). Sending updates on what you ate for lunch is the future of the Net?  I think not. Am I gonna buy books on Twitter?  Buy clothes on Facebook? Once again, I think not. They are niche apps and their total domination of all things Internet is far from certain.



Finally, what technology are all those iPhone apps based on?  Mostly web/browser based technologies. Mobile devices will change the Web and the Net. But replace it? I don't think so.

Monday, 27 September 2010

OS X: Organize Your Desktop by Hiding Apps

os x osx pictureHow do you declutter your Mac desktop of all those open applications? Well of course you can minimize them, like you would in Windows, but that adds them to the doc which just creates another clutter problem.



The Mac way to do this is to hide the applications. This works similar to the way Windows 7 minimizes apps when you click on an app on the taskbar. Hiding an app makes it disappear from the desktop, but it remains running in the dock. You can hide your current application or hide all the other running applications. This can be done from the menu, the keyboard, or with the mouse.



Menu Method

From the currently running application, click on the application name (e.g., if Chrome has the focus, "Chrome" will appear in the application menu). Half way down the menu, the following options are available.



  • Hide AppNameHere

  • Hide Others

  • Show All



The options are pretty self explanatory.



Keyboard Method

Command-H - Hides the current app

Option-Command-H - Hide the other applications



Mouse Method

Option-Click Dock Icon - Hides the app selected by the click on the Dock.

Option-Command-Click Dock Icon - Hides the Other Apps and not the app just clicked on.



Note: Command = AppleKey on a Mac keyboard. (This is not the Control key.)

Sunday, 26 September 2010

Apple Earbuds Cheat Sheet

iphone ipadHey Apple fans. I never realized how much you could do with the latest Apple earbuds/headphones. Not only can you control the volume, but you can fast forward, skip a song, answer the phone, and a number of other things. Apple includes an instruction manual with the earbuds, but that is so 1980s and who wants to carry that around?



So here it is, the unofficial Apple Earbuds cheat sheet. If you want to save the page for offline use, click the link at the bottom of the page and bookmark that. Enjoy.



Unofficial Apple Earbud Cheat Sheet

Saturday, 25 September 2010

Android SDK Tools Revision 7 is available

SDK Tools, Revision 7 (September 2010) is available.



You can refer to my article to know how to Install Android SDK on Eclipse 3.5 Galileo, in Ubuntu 9.10. Or, if you have install Android 1.6 SDK or later version, you can refer to another article to upgrade Android SDK using Android SDK and AVD Manager.

Dependencies:

If you are developing in Eclipse with ADT, note that SDK Tools r7 is designed for use with ADT 0.9.8 and later. After installing SDK Tools r7, we highly recommend updating your ADT Plugin to 0.9.8.

General notes:
  • Added support for library projects that depend on other library projects.
  • Adds support for aidl files in library projects.
  • Adds support for extension targets in Ant build to perform tasks between the normal tasks: -pre-build, -pre-compile, and -post-compile.
  • Adds support for "headless" SDK update. See android -h update sdk for more information.
  • Fixes location control in DDMS to work in any locale not using '.' as a decimal point.

To determine what revision of the SDK Tools you are using, refer to the "Installed Packages" listing in the Android SDK and AVD Manager.




Thursday, 23 September 2010

android-ui-utils: Android UI Utilities


android-ui-utils is a set of utilities that help in the design and development of Android application user interfaces. This library currently consists of three individual tools for designers and developers:

1. UI Prototyping Stencils

2. Android Asset Studio

3. Android Icon Templates

WARNING: These utilities are currently in beta.

Project Home: http://code.google.com/p/android-ui-utils/

Android UI Utilities Beta Demo

A screencast demo of the the new Android UI Utilities project. This demo highlights the stencil kit for Pencil and the Android Asset Studio, both available at http://code.google.com/p/android-ui-u...

Wednesday, 22 September 2010

The Future of JavaFX and Swing

Duke WavingWhat is the plan for JavaFX and Swing? Well JavaFX is going to become a part of the Java API and JavaFX script is going away. For details check out these links.

Tuesday, 21 September 2010

JDK 7, JDK 8 and the Future of Java

Duke WavingOracle Open World and Java One are going on this week. So there have been a lot of announcements about Java and its' future. Here are three links that sum things up well.

Lot's of exciting stuff for us to work on at Oracle! 

Sunday, 19 September 2010

6 Great News Sites for Your iPhone or Mobile Phone

While experimenting a bit with my iPhone, I found several of the best news sites on the Net actually have really good mobile interfaces. Often, the websites have better interfaces and more information than their iPhone app counterpart. In addition, these sites are likely to work well on Android and other mobile devices.



Here is the list:

  1. BBC

  2. CNN

  3. Fox News

  4. Google News

  5. New York Times

  6. Yahoo News



On an iPhone, you can add a website to your desktop so it looks just like an app. To do this, navigate to the website in Safari. Then select the plus (+) and then "Add to Home Screen". This adds a an icon for the website on the currently selected page.

Friday, 17 September 2010

Vacation is almost over...



I've been on vacation for a little over a week. Don't worry I have not forgotten you :) When I return (Tuesday) I plan on continuing the planned changes for TinyUmbrella. In the meantime, stay away from 4.1 and all 4.2 betas if you value your unlock! Although the baseband preservation should work just fine for both of those versions, I would not recommend updating to those simply because a public jailbreak does not exist.

Wednesday, 15 September 2010

iPad Validating eBook Readers

According to WSJ, iPads are not killing the sales of eBook readers. In fact, they seem to be accelerating their sales. This makes sense to me. First, the iPad and future tablets are driving down the prices of the readers. In addition, Kindle for the iPad validates the usefulness of having all your books in electronic form.

Tuesday, 14 September 2010

The Death of RSS and Web Greatly Exaggerated

It seems that with the shutdown of the Bloglines web site, some folks think this spells the end of RSS. And Wired Magazine thinks the Web is dead.  The rise of Skype, Facebook, and RSS are gonna kill it. It seems rumors of demise are everywhere and are also greatly exaggerated.



Yes, iPhone applications, Twitter and Facebook are on the rise. The last two sites are firmly based on Web technology and both offer RSS feeds to tracking account information. Frankly, an RSS feed for a few select Twitter accounts provides a much better way to read the site than trying to watch the fire hose that is your twitter feed. And most of those mobile phone applications are simply custom web applications, nothing more.



Now if you are talking about using your browser on a desktop computer to surf, I think that is on the way down. More and more surfing, buying, you name it on the web, is gonna be done on laptops, netbooks, tablets, and phones. All these smaller devices are gonna have browsers and browsing capabilities much more powerful than desktops have today.



The Web and RSS are not gonna die. But the way we use these technologies is changing fast.



A Real Linux/Unix Terminal for Windows with Cygwin

Linux LogoIf you have not heard of it before, Cygwin is a set of Linux/Unix utilities made to run on Windows. Cygwin includes a plethora of tools including databases, programming languages, and command line utilities. But what I use it for mostly is to have a bash shell for Windows. That allows me to use most of the aliases, symbolic links, and other tricks I use to navigate Linux or Mac OS/X on Windows. It also makes file manipulation a lot easier.



The default Cygwin installation uses the same command window as the Windows command prompt. Which is a little clunky, to say the least. Specifically, cutting and pasting text is a pain in the rear. You have to jump back and forth to the menu to cut and paste text. It is slow, clunky, and annoying.



The solution. Install rxvt with Cygwin. This is a terminal emulator that gives you all those cool cut and paste shell features on Windows. Just install rxvt from the shell options as part of your Cygwin install. Then, create a batch file like this in your Cygwin directory.



@echo off

C:

chdir \cygwin\bin

start rxvt -sr -sl 10000 -fg white -bg black -fn Consolas-20 -fb Consolas-20 -fm Consolas-20 -tn cygwin -e /bin/bash --login -i






I called my file, term.bat. Run the bat file and you get a bash shell and window that behaves just like it would on Linux or a Mac. Yays!



Credit to c2.com for a pointer that got me started on this.

Monday, 13 September 2010

javax.naming.NamingException: Lookup failed for 'jdbc/dbname' in SerialContext

Duke WavingWhile trying to deploy a Java EE6 Web application with NetBeans and Glassfish V3, the application deployment fails with the following error.



SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'jdbc/dbname' in SerialContext [Root exception is javax.naming.NameNotFoundException: dbname not found]


What does this mean? Basically, you have not defined the JDBC resource in the Web Application. In my case, neither the Database Connection Pool nor the JDBC resource had been defined. Once the persistence resources are defined, the application should deploy without any errors.



When first analyzing the problem, I thought, incorrectly, that since the persistence resources were defined in an included library, no definition was required in the Web application. This is not the case.



Update

A reader made a fair point that no pointers on how to create the JDBC resource or Connection Pool are included in this post. Here are the steps assuming you already have a Java EE project created. Right click your project and select the following menu options.

  • Connection Pool New -> Other -> Glassfish -> JDBC Connection Pool

  • JDBC Resource New -> Other -> Glassfish -> JDBC Resource

The wizard for each will walk you through the setup. Hope that helps.

Sunday, 12 September 2010

Tablet Support Android a Ways Off

Google LogoAccording to this Mashable story, tablet support for Android is still a ways out. Real support will have to wait until Android v3.



I'm kind of surprised that Google is this far behind. Expect Apple to up the ante with an iPad 2 in the spring.

Thursday, 9 September 2010

How to set battery status of Android Emulator using the Emulator Console

In last two exercise "Detect Battery Level" and "Detect Battery Info", the apps about battery checking have been built. We have to set the battery status on Android Emulator to check our apps. To change the battery status on Android Emulator, Emulator Console can be used.

To connect to the console of any running emulator instance at any time, use this command:

telnet localhost <console-port>

Where <console-port> is the number shown on your emulator.

Details of the usage, refer to the section Using the Emulator Console of the document Android Emulator.

Wednesday, 8 September 2010

TinyUmbrella with 4.1 Support





UPDATE: It appears Apple is not signing 4.0.2 SHSH requests anymore. As a result I've updated TinyUmbrella to 4.1.4 which will default to grab the 4.1 SHSH for iDevices (3.2.2 for iPads).




I put my money where my mouth is. I tested my code on my own iPhone 4 and was able to update to 4.1 without touching my baseband.

The only doctoring I did was removing my private info. The newest version of TinyUmbrella will have an added side-benefit of allowing you to update to 4.1 without the fear of baseband update. Of course, in order to downgrade back to 4.0.x you need to have your SHSH saved on Cydia or locally. Have fun :)





I've also seen a TON of questions about how to update from 4.0.x to 4.1 WITHOUT updating your baseband. I'll give you a quick rundown of how to do it.



  • Get the latest TinyUmbrella (4.1.3)

  • READ THE README TinyUmbrella README NOW Yes. You Read it.

  • Run TinyUmbrella.

  • Start TSS Server

  • Open iTunes

  • Restore 4.1 (NOT UPDATE) Yes this requires you to download 4.1 Here

  • Let iTunes error with 1004 error (baseband update failed - we want this :) )

  • Kick Device Out of Recovery

  • \o/ -- You are now on 4.1 with 1.59.00 baseband!

Also, here is another good tutorial with more details.



I have heard a few folks voice concerns about how they can downgrade their 2.x baseband to 1.59.00 on iPhone4. Here are the basic steps:



  • Close TinyUmbrella (if open)

  • Close iTunes (if open)

  • Remove ALL lines in your hosts file that contain gs.apple.com

  • Windows: Start -> cmd -> ipconfig /flushdns

  • Mac: Terminal -> dscacheutil -flushcache

  • Start iTunes

  • Restore (NOT UPDATE) Stock 4.0.2 iPhone 4 - 4.0.2 Download

Note that this will only work while Apple is signing 4.0.2 SHSH requests. This is due to the way Apple now updates/restores Baseband Firmware for the iPhone 4 different from the way it did to prior devices. Lucky us...

Firefox Browser Gaming Competition

Firefox LogoThe Mozilla foundation is sponsoring a browser based gaming competition. Details from Mashable.



This a great idea. It will make a lot more developers aware of what is possible in a modern browser. Plus we should get some cool games out of it. :)

Detect Battery Info.

In the last exercise "Detect Battery Level", the app simple detect the battery level only. It's modified to have more info to be displayed, include: battery level, voltage, temperature, technology, charging status, and health of the battery.

Detect Battery Info.

main.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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Battery Info."
/>
<TextView
android:id="@+id/batterylevel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Battery Level:"
/>
<TextView
android:id="@+id/batteryvoltage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Battery Voltage:"
/>
<TextView
android:id="@+id/batterytemperature"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Battery Temperature:"
/>
<TextView
android:id="@+id/batterytechology"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Technology:"
/>
<TextView
android:id="@+id/batterystatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Status:"
/>
<TextView
android:id="@+id/batteryhealth"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Health:"
/>
</LinearLayout>


AndroidBattery.java
package com.exercise.AndroidBattery;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidBattery extends Activity {

private TextView batteryLevel, batteryVoltage, batteryTemperature,
batteryTechnology, batteryStatus, batteryHealth;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

batteryLevel = (TextView)findViewById(R.id.batterylevel);
batteryVoltage = (TextView)findViewById(R.id.batteryvoltage);
batteryTemperature = (TextView)findViewById(R.id.batterytemperature);
batteryTechnology = (TextView)findViewById(R.id.batterytechology);
batteryStatus = (TextView)findViewById(R.id.batterystatus);
batteryHealth = (TextView)findViewById(R.id.batteryhealth);

this.registerReceiver(this.myBatteryReceiver,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

private BroadcastReceiver myBatteryReceiver
= new BroadcastReceiver(){

@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub

if (arg1.getAction().equals(Intent.ACTION_BATTERY_CHANGED)){
batteryLevel.setText("Level: "
+ String.valueOf(arg1.getIntExtra("level", 0)) + "%");
batteryVoltage.setText("Voltage: "
+ String.valueOf((float)arg1.getIntExtra("voltage", 0)/1000) + "V");
batteryTemperature.setText("Temperature: "
+ String.valueOf((float)arg1.getIntExtra("temperature", 0)/10) + "c");
batteryTechnology.setText("Technology: " + arg1.getStringExtra("technology"));

int status = arg1.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
String strStatus;
if (status == BatteryManager.BATTERY_STATUS_CHARGING){
strStatus = "Charging";
} else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING){
strStatus = "Dis-charging";
} else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING){
strStatus = "Not charging";
} else if (status == BatteryManager.BATTERY_STATUS_FULL){
strStatus = "Full";
} else {
strStatus = "Unknown";
}
batteryStatus.setText("Status: " + strStatus);

int health = arg1.getIntExtra("health", BatteryManager.BATTERY_HEALTH_UNKNOWN);
String strHealth;
if (health == BatteryManager.BATTERY_HEALTH_GOOD){
strHealth = "Good";
} else if (health == BatteryManager.BATTERY_HEALTH_OVERHEAT){
strHealth = "Over Heat";
} else if (health == BatteryManager.BATTERY_HEALTH_DEAD){
strHealth = "Dead";
} else if (health == BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE){
strHealth = "Over Voltage";
} else if (health == BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE){
strHealth = "Unspecified Failure";
} else{
strHealth = "Unknown";
}
batteryHealth.setText("Health: " + strHealth);

}
}

};
}


Download the files.

Related Article:
- Home Screen Battery Widget



Tuesday, 7 September 2010

TinyUmbrella - New Updates with 4.1 looming...

EDIT: I just got a report of someone getting their baseband updated even though the protection was in place. DO NOT UPDATE to 4.1 unless you absolutely have to. I need to look at what happened in this case.





Let me preface this by saying that it is important that you do not update to 4.1 if you wish to keep your unlock and jailbreak.

I've updated TinyUmbrella in anticipation of the imminent release of iOS 4.1. Here are some notable features. (Sorry I have not finished the changes I mentioned previously as these features I felt were VERY important with 4.1 coming)

  • Baseband Protection - Updating to 4.1 using TinyUmbrella will protect your baseband from update. THIS ONLY APPLIES TO IPHONE 4!!!!! If you have a 3G or 3GS and you update to 4.1 your baseband will likely be updated.

  • SHSH Retrieval from Cydia - If you don't have your SHSH locally, TinyUmbrella will request them from Cydia on-demand; allowing the restore to continue

  • Automatically point hosts to Cydia - Once you close TinyUmbrella, it points your hosts file to Cydia (for further baseband protection and update/restores without TinyUmbrella)

I hope it helps.

EDIT: I've also added iPod Touch 4G 4.1 support :)

Detect Battery Level

It's a exercise of Android App to detect battery level.

Detect Battery Level

A BroadcastReceiver, myBatteryReceiver, is implemented and registered to receive ACTION_BATTERY_CHANGED, and retrieve "level" via getIntExtra() method.

main.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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:id="@+id/batterylevel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Battery Level:"
/>
</LinearLayout>


AndroidBattery.java
package com.exercise.AndroidBattery;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidBattery extends Activity {

private TextView batteryLevel;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

batteryLevel = (TextView)findViewById(R.id.batterylevel);
this.registerReceiver(this.myBatteryReceiver,
new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}

private BroadcastReceiver myBatteryReceiver
= new BroadcastReceiver(){

@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
int bLevel = arg1.getIntExtra("level", 0);

batteryLevel.setText("Battery Level: "
+ String.valueOf(bLevel) + " %");
}

};
}


Download the files.

Related Article: Detect Battery Info.

Monday, 6 September 2010

PHP: Call to a member function on a non-object

PHP LogoRan across a PHP thinking in Java problem today. Say you have some code like this:



class MyClass{
private $myObject;

public function MyClass(){
$myObject = new MyObject()
}

}
As soon as the $myObject variable is accessed the following error is thrown: Call to a member function on a non-object.



What?????



This is PHP not Java nimrod. :) $myObject is not getting initialized because the syntax is incorrect. Try this:

class MyClass{
private $myObject;

public function MyClass(){
$this->myObject = new MyObject()
}

}
That should fix it right up. This sort of stuff always happens to me as I bounce between languages. lol.

Friday, 3 September 2010

iOS 4.1 and iTunes 10

Although it may be tempting to update to iOS 4.1 when it comes out, make sure you pay heed to the Dev Team warnings.



  1. iOS 4.1 is not currently jailbroken - you WILL lose your jailbreak

  2. iOS 4.1 contains a new baseband - you WILL lose your carrier unlock as provided by ultrasn0w.

  3. If you ignore the warning and update to 4.1, you can downgrade to whatever version you have SHSH for (either locally or on-file at Cydia. So if TinyUmbrella shows SHSH for 4.0.1, you can downgrade to that version. That said - you cannot downgrade your baseband /ever/. Once you update to a firmware with a new baseband, you are stuck on that baseband regardless of firmware downgrade.

I plan on supporting iOS 4.1 when it is released and hopefully I'll have the UI changes as well as the rare PPC / crash issues worked out.
I've taken a quick look at iTunes 10 and don't see any immediate issues with local restores but as always, please hold off on updating to new versions of iTunes unless you absolutely have to have a feature it provides.

Thursday, 2 September 2010

Copy and Paste using ClipboardManager

ClipboardManager is a interface to the clipboard service, for placing and retrieving text in the global clipboard.

You do not instantiate this class directly; instead, retrieve it through getSystemService(String).

Copy and Paste using ClipboardManager

main.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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText
android:id="@+id/src"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/dest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/copynpaste"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Copy'n Paste"
/>
</LinearLayout>


AndroidCopynPaste.java
package com.exercise.AndroidCopynPaste;

import android.app.Activity;
import android.os.Bundle;
import android.text.ClipboardManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AndroidCopynPaste extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

final EditText src = (EditText)findViewById(R.id.src);
final TextView dest = (TextView)findViewById(R.id.dest);
Button copynPaste = (Button)findViewById(R.id.copynpaste);

final ClipboardManager clipBoard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);

copynPaste.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
clipBoard.setText(src.getText());
dest.setText(clipBoard.getText());

}});
}
}



Download the files.