You can use a service for both the tasks.
for the first one, invoke the service, when the downloading is going to start.
Use a thread in the service that is executed after a while that checks for the active internet connection.
Edit-
It could be something like,
Thread thread = new Thread()
{
@Override
public void run() {
try {
while(true) {
sleep(1000);
Toast.makeText(getBaseContext(), "Running Thread...", Toast.LENGTH_LONG).show();
// Check internet connectivity here
}
} catch (InterruptedException e) {
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
}
}
};
thread.start();
Have a look at this post also.
Also I have found two other options,
Have a look at Timer Task and Alarm Manager also to check internet connection after a while.