How to pass context in Async Task class which is coded in different java file from Main Activity but it called from main activity?
Below is
I encountered same issue when trying to compress an image using an Async class. I had a constructor in place so I just added context as below
public BackgroundImageResize(Context context, Bitmap bm) {
if (bm != null){
mBitmap = bm;
}
this.context =context;
}
Then i called the class like below,
public void uploadDevicePhoto(Uri imageUri){
BackgroundImageResize resize = new BackgroundImageResize(this,null);
resize.execute(imageUri);
}