1 package ${packageName};
3 import android.app.IntentService;
4 import android.content.Intent;
5 <#if includeHelper>import android.content.Context;</#if>
8 * An {@link IntentService} subclass for handling asynchronous task requests in
9 * a service on a separate handler thread.
12 * TODO: Customize class - update intent actions, extra parameters and static
15 * TODO: Customize class - update intent actions and extra parameters.
18 public class ${className} extends IntentService {
20 // TODO: Rename actions, choose action names that describe tasks that this
21 // IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS
22 public static final String ACTION_FOO = "${packageName}.action.FOO";
23 public static final String ACTION_BAZ = "${packageName}.action.BAZ";
25 // TODO: Rename parameters
26 public static final String EXTRA_PARAM1 = "${packageName}.extra.PARAM1";
27 public static final String EXTRA_PARAM2 = "${packageName}.extra.PARAM2";
29 // TODO: Rename actions, choose action names that describe tasks that this
30 // IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS
31 private static final String ACTION_FOO = "${packageName}.action.FOO";
32 private static final String ACTION_BAZ = "${packageName}.action.BAZ";
34 // TODO: Rename parameters
35 private static final String EXTRA_PARAM1 = "${packageName}.extra.PARAM1";
36 private static final String EXTRA_PARAM2 = "${packageName}.extra.PARAM2";
39 * Starts this service to perform action Foo with the given parameters. If
40 * the service is already performing a task this action will be queued.
44 // TODO: Customize helper method
45 public static void startActionFoo(Context context, String param1, String param2) {
46 Intent intent = new Intent(context, ${className}.class);
47 intent.setAction(ACTION_FOO);
48 intent.putExtra(EXTRA_PARAM1, param1);
49 intent.putExtra(EXTRA_PARAM2, param2);
50 context.startService(intent);
54 * Starts this service to perform action Baz with the given parameters. If
55 * the service is already performing a task this action will be queued.
59 // TODO: Customize helper method
60 public static void startActionBaz(Context context, String param1, String param2) {
61 Intent intent = new Intent(context, ${className}.class);
62 intent.setAction(ACTION_BAZ);
63 intent.putExtra(EXTRA_PARAM1, param1);
64 intent.putExtra(EXTRA_PARAM2, param2);
65 context.startService(intent);
69 public ${className}() {
70 super("${className}");
74 protected void onHandleIntent(Intent intent) {
76 final String action = intent.getAction();
77 if (ACTION_FOO.equals(action)) {
78 final String param1 = intent.getStringExtra(EXTRA_PARAM1);
79 final String param2 = intent.getStringExtra(EXTRA_PARAM2);
80 handleActionFoo(param1, param2);
81 } else if (ACTION_BAZ.equals(action)) {
82 final String param1 = intent.getStringExtra(EXTRA_PARAM1);
83 final String param2 = intent.getStringExtra(EXTRA_PARAM2);
84 handleActionBaz(param1, param2);
90 * Handle action Foo in the provided background thread with the provided
93 private void handleActionFoo(String param1, String param2) {
94 // TODO: Handle action Foo
95 throw new UnsupportedOperationException("Not yet implemented");
99 * Handle action Baz in the provided background thread with the provided
102 private void handleActionBaz(String param1, String param2) {
103 // TODO: Handle action Baz
104 throw new UnsupportedOperationException("Not yet implemented");