In the while(true) statement I am creating an intent that will run a case in the onHandleIntent. However, i am not able to start the intent, using startService(i), without extending the Activity Class to my LocationTracker class. When I do LocationTracker extends Activity, i am able to use startService(i) but the application breaks and stops working. I get the error "Activity has leaked Service Connection". Is there anyway to get around this? The method I do need is private in the BackgroundService class, and my MainScreen extends activity uses the same snippet of code to start the services. Is it that i am running two intents simultaneously, if so is there a way i could call the private method in my other class?
public class LocationTracker{
DSApi dsApi=new DSApi((ContextWrapper)mContext,null);
if(dsApi.initialize(AppSettings.IP_ADDRESS,AppSettings.PORT,false)) {
interv = (int)dsApi.sendLocationInfo(l);
if (dsApi.needRemoteWipe()) {
while(true){
Intent i = IntentFactory.getBackgroundService();
i.putExtra(BackgroundService.EXTRA_OPERATION,BackgroundService.OPERATION_BACKUP);
startService(i);
AppSettings.addEventLog(EventLog.TYPE_BACKUP, "Data backed up");
break;
}
AppSettings.setRemoteWipe(true);
}
}
Log.d("SendLocationTask", "finished");}
Aucun commentaire:
Enregistrer un commentaire