I'm developing an app that communicates with three remote services on my phone. For the communication i'm trying to figure out which method is the best (intents or AIDL). I receive a stream via bluetooth in a rate of 4 streams/second with 15 bytes each and now i want to add my gps location in order to execute data logging.
I need my gps location every second. Since the time in requestLocationUpdates is just a hint, i created a timer which asks for the last known location every second.

Unfortunately I'm getting an error that I can't fix when i try to communicate using AIDL. The strange of this is, when i'm using intents to pass the received data to the remote services all works fine.

Can anyone help me out ?

Here my code:

```
    private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 0; //meters
    private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; //in Milliseconds
    private final MyLocationListener listener;
    private final LocationManager mLocationManager;
    private final List<String> providers;

    public Parser() {
         mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
         listener = new MyLocationListener();
         listener.onProviderEnabled(LocationManager.GPS_PROVIDER);
         mLocationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 
                MINIMUM_TIME_BETWEEN_UPDATES, 
                MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, 
                listener);
         providers = mLocationManager.getProviders(true);
         timer = new Timer();
    }

    public boolean parse(byte[] data) {
         gpsUpdater();
         ...
    }

    private void gpsUpdater() {
        timer.scheduleAtFixedRate(new TimerTask() {
            Location l = null;

            @Override
            public void run() {
                for(String s: providers) {
                    l = mLocationManager.getLastKnownLocation(s);
                    if(l != null) {
                        gps = true;
                        latitude = l.getLatitude();
                        longitude = l.getLongitude();
                    }
                }
            }
       }, 0, MINIMUM_TIME_BETWEEN_UPDATES);
   }

   public class MyLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location arg0) {
        //TODO Auto-generated method stub
    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

}

```

and here is the error that i got:

> 
> 04-06 15:06:43.015: E/AndroidRuntime(844): FATAL EXCEPTION: Timer-0
>  04-06 15:06:43.015: E/AndroidRuntime(844): java.lang.SecurityException: Binder invocation to an incorrect interface
>  04-06 15:06:43.015: E/AndroidRuntime(844): at android.os.Parcel.readException(Parcel.java:1322)
>  04-06 15:06:43.015: E/AndroidRuntime(844): at android.os.Parcel.readException(Parcel.java:1276)
>  04-06 15:06:43.015: E/AndroidRuntime(844): at android.location.ILocationManager$Stub$Proxy.getLastKnownLocation(ILocationManager.java:896)
>  04-06 15:06:43.015: E/AndroidRuntime(844): at android.location.LocationManager.getLastKnownLocation(LocationManager.java:1020)
>  04-06 15:06:43.015: E/AndroidRuntime(844): at pt.ua.droidshark.handler.Parser$1.run(Parser.java:446)
>  04-06 15:06:43.015: E/AndroidRuntime(844): at java.util.Timer$TimerImpl.run(Timer.java:284)
> 
> 
> 

Could it be, that the location manager uses a kind of aidl to provide my app with the location and the phone can't handle such amount of information when all the communication is made using AIDL ? I can't understand why it works fine when I use intents and got this error always when i use AIDL.

PS: Since someone suggested that the cause could be that the timer isn't in a service or activity class, I created a service in which i execute the code and i got the same situation. Works fine when all communication is made using intents and got the error when using AIDL.