0

I have an Asynctask that last longer than i would like my users to be waiting at the submit screen.

I am currently using asynctask.get(..) but i would like my users to be able to carry on using the app while the Asynctask runs in the background.

How would i display a message to the user when my Asynctask wont hold a reference to the current context?

Thanks

Rik1988
  • 25
  • 1
  • 6

1 Answers1

2

I couldn't undestand very well your problem but remember this:

If your AsyncTask finish his job and you have references to an destroyed activity you could get null pointer exceptions and your app will crash.

Also AsyncTaks are not designed to perform long tasks, maybe your best option is using IntentService and if you want to notify to the UI you can use BroadcastReceivers.

  • 1
    Hi, thanks for your answer. It looks like IntentService is what I need. I'm uploading images and video to a server in the background, and want my user to be able to freely use the application (switch between activities) and be notified when the upload finishes. I will look more into this and Mark your answer as correct if it what I need. Thanks – Rik1988 Aug 23 '17 at 02:45