Picasso java.lang.IllegalStateException: Method call should not happen from the main thread

后端 未结 5 2053
后悔当初
后悔当初 2021-01-07 22:32

I am attempting to use Picasso to get three Bitmap images from a URL

public void onCreate(Bundle savedInstanceState) { 
  super.onC         


        
5条回答
  •  不知归路
    2021-01-07 23:19

    You cannot make synchronous requests in the main thread. If you dont want to use an AsyncThread then just use Picasso together with a Target.

    Picasso.with(Tab2.this).load(zestimateImg1).into(new Target(...);
    

    I recommend you save a reference to your target like so:

    Target mTarget =new Target (...); 
    

    This is because Picasso uses weak references to them and they might be garbage collected before the process is finished.

提交回复
热议问题