I have a folder in which i store images....So what i want to do is upload this images to server and once the upload is complete i want to delete this images.. This uploading and deleting should happen in background...So i have created a service that works fine..What i want is whenever a new file comes in this folder it should automatically upload..i.e the service should automatically start itself...Is there any way to do this...??
public class MyServices extends Service {
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Service Started",
Toast.LENGTH_LONG).show();
sendfile();
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Service Stopped",
Toast.LENGTH_LONG).show();
super.onDestroy();
}
}
the sendfile() scans the folder and sends the images....So do i have to keep on calling this method infinitely or is there any other way???