-
IllegalStateException not on main thread
about 9 years ago
-
about 9 years ago
Hello,
Please check the following code and replace it with yours
class LoadImage extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... urls) { Bitmap theBitmap = null; Log.e("", "Wow It has to work"); try { theBitmap = Glide. with(act). load("https://graph.facebook.com/998365793528829/picture?type=large"). asBitmap(). into(100, 100). // Width and height get(); BitmapDescriptor iconBitmap = BitmapDescriptorFactory.fromBitmap(theBitmap); // map.addMarker(new MarkerOptions() // .icon(iconBitmap) // .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left // .position(new LatLng(19.129980, 72.834795))); final Bitmap finalTheBitmap = theBitmap; act.runOnUiThread(new Runnable() { @Override public void run() { map.addMarker(new MarkerOptions() .position(new LatLng(19.129980, 72.834795))) .title("Melbourne") .snippet("Population: 4,137,400") .icon(BitmapDescriptorFactory.fromBitmap(finalTheBitmap)); } }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { } }
If this answer solved your problem mark it correct .
Happy Coding :) :)
-
-
about 9 years ago
-
-
about 9 years ago
-
3 Answer(s)