]>
Commit | Line | Data |
---|---|---|
1 | package de.rmdir.ms2debounce; | |
2 | ||
3 | import android.app.Service; | |
4 | import android.content.Intent; | |
5 | import android.content.Context; | |
6 | import android.os.IBinder; | |
7 | import android.os.AsyncTask; | |
8 | import android.util.Log; | |
9 | ||
10 | public class DebounceBootService extends Service | |
11 | { | |
12 | private static final String TAG = "DebounceBootService"; | |
13 | ||
14 | public IBinder onBind(Intent intent) | |
15 | { | |
16 | return null; | |
17 | } | |
18 | ||
19 | @Override | |
20 | public void onCreate() | |
21 | { | |
22 | Log.i(TAG, "Starting AsyncTask"); | |
23 | new AsyncTask<DebounceBootService, Void, Void>() { | |
24 | @Override | |
25 | protected Void doInBackground(DebounceBootService... svc) { | |
26 | Context context = getApplicationContext(); | |
27 | DebounceModuleHelper module = new DebounceModuleHelper(context); | |
28 | ||
29 | Log.i(TAG, "Loading Module"); | |
30 | ||
31 | try { | |
32 | module.loadModule(); | |
33 | } catch (Exception e) { | |
34 | Log.e(TAG, "Got Exception: " + e.getMessage() + " (" + e.getCause() + ")"); | |
35 | } | |
36 | ||
37 | svc[0].stopSelf(); | |
38 | ||
39 | return null; | |
40 | } | |
41 | }.execute(this); | |
42 | } | |
43 | ||
44 | @Override | |
45 | public int onStartCommand(Intent intent, int flags, int startId) | |
46 | { | |
47 | Log.i(TAG, "Creating STICKY service"); | |
48 | return START_STICKY; | |
49 | } | |
50 | ||
51 | @Override | |
52 | public void onDestroy() | |
53 | { | |
54 | Log.i(TAG, "Destroying service"); | |
55 | } | |
56 | } |