Hi i m using Android Studio, and I am using Deprecated function in a runOnUiThread It forces me to use a a Final Variable inside the runOnUiThread this is ok for the new function but for the Deprecated function i get an error
Error:(133, 16) error: incompatible types
required: Thread
found: void
anyone can help to fix this.
Thread thread = new Thread() {
public void run() {
try {
String sURL = "http://pollsdb.com/schlogger/223.png";
URL url = null;
url = new URL(sURL);
assert url != null;
Bitmap bmp = null;
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
bmp = Bitmap.createScaledBitmap(bmp, 200, 200, false);
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bmp);
final BitmapDrawable fbmpdw = bitmapDrawable;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ib1.setBackground(fbmpdw);
} else {
ib1.setBackgroundDrawable(fbmpdw); // <---- this the problem
}
}
});
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();