Skip to content

Commit

Permalink
setting up service to start at application launch
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsteele committed Apr 1, 2011
1 parent 7ef86fe commit a98691f
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 8 deletions.
4 changes: 4 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustResize" >
</activity>
<service android:enabled="true"
android:name=".service.GeoLocationServiceImplementation">
</service>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
6 changes: 6 additions & 0 deletions android/src/gov/nasa/arc/geocam/memo/GeoCamMemoModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import gov.nasa.arc.geocam.memo.service.DjangoMemoInterface;
import gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterImplementation;
import gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface;
import gov.nasa.arc.geocam.memo.service.GeoLocationListenerImplementation;
import gov.nasa.arc.geocam.memo.service.GeoLocationListenerInterface;
import gov.nasa.arc.geocam.memo.service.GeoLocationServiceImplementation;
import gov.nasa.arc.geocam.memo.service.GeoLocationServiceInterface;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
Expand All @@ -20,6 +24,8 @@ protected void configure() {
bind(DjangoMemoJsonConverterInterface.class)
.to(DjangoMemoJsonConverterImplementation.class);
bind(HttpClient.class).toInstance(new DefaultHttpClient());
bind(GeoLocationListenerInterface.class).to(GeoLocationListenerImplementation.class);
bind(GeoLocationServiceInterface.class).to(GeoLocationServiceImplementation.class);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

public class GeoCamMemoRoboApplication extends RoboApplication{
private Module module = new GeoCamMemoModule();

@Override
public void onCreate() {

}

protected void addApplicationModules(List<Module> modules) {
modules.add(this.module);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package gov.nasa.arc.geocam.memo.service;

import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;

public class GeoLocationListenerImplementation
implements LocationListener, GeoLocationListenerInterface {
implements GeoLocationListenerInterface {

private Location curLocation;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package gov.nasa.arc.geocam.memo.service;

import android.location.Location;
import android.location.LocationListener;

public interface GeoLocationListenerInterface {
public interface GeoLocationListenerInterface extends LocationListener {
public Location getLocation();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package gov.nasa.arc.geocam.memo.service;

import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.os.IBinder;

import com.google.inject.Inject;

public class GeoLocationServiceImplementation extends Service
implements GeoLocationServiceInterface {

@Inject GeoLocationListenerInterface listener;
@Inject LocationManager locationManager;

@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public void onCreate() {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 1, listener);
}

@Override
public Location getLocation() {
return listener.getLocation();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.nasa.arc.geocam.memo.service;

import android.location.Location;

public interface GeoLocationServiceInterface {
public Location getLocation();
}

0 comments on commit a98691f

Please sign in to comment.