I have activity class running infinite loop in BackgroundAsyncTask
(see below)
I have a problem trying to "finish" this activity, when i press
"btnClose" the activity window disappears, but when i try to re-start
this activity from "Applications" group i have "null pointer
exception"
java.lang.RuntimeException: An error occured while executing
doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:200)
at java.util.concurrent.FutureTask
$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:
1068)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
Caused by: java.lang.NullPointerException
at mz.com.Console$BackgroundAsyncTask.doInBackground(Console.java:224)
at mz.com.Console$BackgroundAsyncTask.doInBackground(Console.java:1)
Any idea where is null pointer exception coming from and how to do it
right? line 224 corresponds to
inner class BackgroundAsyncTask but what is causing null pointer
exception?
I tried to check for passed params in doInBackground: "if (params ==
null) return" - no difference.
i stuck and would be thankful for the pointers...
-V
public class Console extends Activity {
private BackgroundAsyncTask channel;
onCreate{
...
channel = new BackgroundAsyncTask();
channel.execute();
...
public void onDestroy() {
Log.i("Activity", "onDestroy");
super.onDestroy();
}
buttonClose.setOnClickListener(new View.OnClickListener()
{
channel.cancel(true);
finish();
});
line 224: public class BackgroundAsyncTask extends
AsyncTask<Void, String, Void>
{
boolean loop;
protected void onCancelled()
{
Log.i("Background task", "onCancelled");
loop = false;
}
protected Void doInBackground(Void... params)
{
loop = true;
while(loop)
{
socket.receive();
publishProgress...
...
}
}
} // end of Console
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en