I am attempting to use Picasso to get three Bitmap
images from a URL
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab2);
Drawable d1 = new BitmapDrawable(Picasso.with(Tab2.this).load(zestimateImg1).get());
}
I am getting FATAL EXCEPTION
with this code. I suspect it has to do with the fact that this should be done within AsyncTask
, but I can't get it to work. If using that is avoidable, I would like to do this without using AsyncTask
.
How can I get this code to run without crashing?
If the best way to do this is with AsyncTask
, then that solution is ok.
An IllegalStateException is a runtime exception in Java that is thrown to indicate that a method has been invoked at the wrong time. This exception is used to signal that a method is called at an illegal or inappropriate time.
Class IllegalStateException. Signals that a method has been invoked at an illegal or inappropriate time. In other words, the Java environment or Java application is not in an appropriate state for the requested operation.
IllegalStateException is the child class of RuntimeException and hence it is an unchecked exception.
None of above worked for me instead this
Handler uiHandler = new Handler(Looper.getMainLooper());
uiHandler.post(new Runnable(){
@Override
public void run() {
Picasso.with(Context)
.load(imageUrl)
.into(imageView);
}
});
Hope it may be useful for someone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With