Skip to content

Commit

Permalink
Basic service structure added
Browse files Browse the repository at this point in the history
  • Loading branch information
tallnato committed May 22, 2013
1 parent 275d700 commit 496b6e5
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
9 changes: 8 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name=".MockLocationService"
android:exported="false"
android:label="@string/service_name"
android:process=":mocklocationservice"/>

</application>

</manifest>
1 change: 1 addition & 0 deletions src/com/renatoalmeida/gpxmocklocations/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public class MainActivity extends Activity
{
private static final String TAG = MainActivity.class.getSimpleName();

@Override
protected void onCreate(Bundle savedInstanceState)
Expand Down
55 changes: 55 additions & 0 deletions src/com/renatoalmeida/gpxmocklocations/MockLocationService.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}

0 comments on commit 496b6e5

Please sign in to comment.