I have an application that runs a long process. I am using AsyncTask class to achieve it. But when the phone sleeps the async task automatically stops. To stop this behaviour I want to achieve a partial wakelock when the doInBackgound starts and release it when it ends.
But when I paste the following code in doInBackground method, the getSystemService gives the error that it is undefined for the type myclass.
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
Can you gimme a workaround for this..
What I want to do is..
class doit extends AsyncTask<String, String , Void>
{
@Override
protected Void doInBackground(String... params)
{
//Achieve Partial Wakelock
//Do long Work
//Release Lock
}
}