I have an error code that I do not have a resolver, and I looked for several ways here in stackoverflow
but I did not succeed.
the error that is displayed:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference at softcode.tattostudio.BudgetFragment$1GetImage.onPostExecute(BudgetFragment.java:250) at softcode.tattostudio.BudgetFragment$1GetImage.onPostExecute(BudgetFragment.java:240)
Basic the lines that give the error are:
private void getImage(String urlToImage){
class GetImage extends AsyncTask<String,Void,Bitmap> { //This line is 240
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
imgvShowTattoIMG.setImageBitmap(bitmap); //This line is 250
}
@Override
protected Bitmap doInBackground(String... params) {
URL url = null;
Bitmap image = null;
String urlToImage = params[0];
try {
url = new URL(urlToImage);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
}
GetImage gi = new GetImage();
gi.execute(urlToImage);
}
Anyone have any idea what it could be? Need to post the full code?