Me and my friend Eugeniu Arbuleac had the pleasure to present an Introduction to Android development course at Google Developers Group Bucharest first 2013 meetup.
Use them both Programmatically Initialize new widgets Customize properties for each VS. XML Declare UI in XML Inflate XML in Java files Building Android UI
Service starts and "runs" until it gets a request to stop To offload work from main thread, use intent service. Intent service uses worker thread, stops when done with work. Service Lifecycle
package ro.gdgcluj.demoapp; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class MyService extends Service { static final String TAG = MyService.class.getSimpleName(); @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { Log.d(TAG, "onCreate"); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); return START_STICKY; } @Override public void onDestroy() { Log.d(TAG, "onDestroy"); } } Service Example
Register for certain intents Get notified when intent happens Intent based publish-subscribe mechanism Listening system events: incoming calls, SMS messages a.o. Broadcast Receivers