-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/com/renatoalmeida/gpxmocklocations/MockLocationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |