If you are using it in an static AsyncTask, or any other class, you can pass the activity as a parameter to a method or constructor, for example:
activity onCreate:
//Pass activity variable (this)
new Main2Activity.MyTask().execute(this);
class inside activity:
private static class MyTask extends AsyncTask<Object, Void, String> {
Main2Activity activity;
@Override
protected String doInBackground(Object... params) {
activity = (Main2Activity)params[0];
....
}
@Override
protected void onPostExecute(String str) {
// Use parameter activity passed to class
WebView webView = activity.findViewById(R.id.web_view);
webView.loadData(str, "text/html; charset=UTF-8", null);
}