If you plan to distribute your app through the Android Market, use Android Market Licensing.
There's also a copy-protection option in the Android Market Publisher, but it has been deprecated and Google recommends to use licensing instead.
If you're not distributing the app through the Android Market, I'd recommend looking at the Android Market Licensing source code and implement a similar system with your own server.