From 496b6e571142e16941f01d13ca91934a82f296f4 Mon Sep 17 00:00:00 2001 From: Renato Almeida Date: Wed, 22 May 2013 00:10:35 +0100 Subject: [PATCH] Basic service structure added --- AndroidManifest.xml | 9 ++- .../gpxmocklocations/MainActivity.java | 1 + .../gpxmocklocations/MockLocationService.java | 55 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/com/renatoalmeida/gpxmocklocations/MockLocationService.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ba1a0d8..ccfa6a5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -22,6 +22,13 @@ + + + - + diff --git a/src/com/renatoalmeida/gpxmocklocations/MainActivity.java b/src/com/renatoalmeida/gpxmocklocations/MainActivity.java index dedd32c..882e7bb 100644 --- a/src/com/renatoalmeida/gpxmocklocations/MainActivity.java +++ b/src/com/renatoalmeida/gpxmocklocations/MainActivity.java @@ -5,6 +5,7 @@ public class MainActivity extends Activity { + private static final String TAG = MainActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) diff --git a/src/com/renatoalmeida/gpxmocklocations/MockLocationService.java b/src/com/renatoalmeida/gpxmocklocations/MockLocationService.java new file mode 100644 index 0000000..38fd278 --- /dev/null +++ b/src/com/renatoalmeida/gpxmocklocations/MockLocationService.java @@ -0,0 +1,55 @@ +package com.renatoalmeida.gpxmocklocations; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.util.Log; + +public class MockLocationService extends Service +{ + private static final String TAG = MockLocationService.class.getSimpleName(); + + private final Messenger mMessenger = new Messenger(new IncomingHandler()); + + @Override + public int onStartCommand(Intent intent, int flags, int startId) + { + return START_STICKY; + } + + @Override + public void onCreate() + { + super.onCreate(); + Log.i(TAG, "Service Started."); + } + + @Override + public void onDestroy() + { + super.onDestroy(); + Log.i(TAG, "Service Stopped."); + } + + @Override + public IBinder onBind(Intent intent) + { + return mMessenger.getBinder(); + } + + private class IncomingHandler extends Handler + { + @Override + public void handleMessage(Message msg) + { + switch(msg.what) { + + default: + super.handleMessage(msg); + } + } + } +}