setAccountAuthenticatorResult can be called from the Activity, which extends AccountAuthenticatorActivity. My activity extends that, but launches A
Follow these steps:
1) Create an interface
public interface AsyncTaskListener{
public void updateResult(String result);
}
2) Use the listener in your AsyncTask
DownloadSongTask extends AsyncTask{
private AsyncTaskListener listener;
public DownloadSongTask(Context context)
{
listener= (AsyncTaskListener)context; // Typecast
}
@Override
public void doInbackGround(String... params)
{
// Download code
int downloadPerc = // calculate that
publish(downloadPerc);
}
@Override
public void onPostExecute(String result)
{
listener.updateResult(String result); // Use it
}
}
3) Implement the interface in your Activity and Override the interface method
public class YourActivity extends AppcompatActivity implements AsyncTaskListener{
// Activity code //
new DownloadSongTask(this).execute("Paradise.mp3"); // this is how you start Task
public void yourMethod(String arg)
{
// Your method related Stuff
}
@Override
public void updateResult(String result){
yourMethod(result);
}
}
This seems a lengthy approach at first but if you use this approach
You can make a loosely coupled AsyncTask. Which means you can use same AsyncTask with any Activity in Future without even changing code in your AsyncTask.
For better understanding you can read this ANSWER