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.
不幸的是,在我试图利用国际助老会进行沟通时,我会发现一个错误。 奇怪的是,如果一米故意将所收到数据传送到边远处,则所有工作都属于罚款。
谁能帮助我?
这里我的准则是:
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
}
}
这里的错误是:
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)
地点主管使用某种辅助器向我提供地点和电话,如果所有通信都是利用国际助老会进行,电话能否处理这种数量的信息? 我无法理解,在我使用意向时,它为什么会进行罚款,在使用国际助老会时总是会发现这一错误。
PS:由于有人提议,原因可能是工作班或活动班级的工时人数不足,我设立了一执行守则和一概情况相同的服务。 如果所有通信都使用意向进行,并在使用《国际公路货运公约》时发现错误,将予以罚款。