tags:

views:

64

answers:

2

I have a comment activity that loads a Thread and sends some data to a server, the activity is immediately finished once the submit button is pressed. The user is then free to do other things in my application.

When the server response an AlertDialog is shown.

The problem is that since the initial Context has been destroyed, my application crashes. I tried getApplicationContext() but still get an exception.

+4  A: 

Put your network stuff in a Service, then show a status bar notification instead of a dialog.

Mirko Nasato
This is not a bad idea actually. I may go this route if I cannot find another way around this problem.
jax
A: 

Take a look at AsyncTask

From JavaDocs: AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

phogel
I can do this but I still have the context problem. I pass the context to the Threaded task.
jax