When I run below code in the onPostExecute, it gives me an exception: java.lang.NullPointerException
getApplicationContext().getResources().getString(R.string.lbl_sth);
getBaseContext().getResources().getString(R.string.lbl_sth);
R.string.lbl_sth
is definitely correct. If I run above two lines in onCreate
, both lines work as expected.
Don't use
getBaseContext()
in yourAsyncTask
... pass yourActivity
as a context to theAsyncTask
instead. Then callgetResources().getString(...)
on theActivity
directly.