I currently have a fragment that generates an ImageView. I am in search of a way to be able to update the imageview that is generated every 30 seconds. The imageview uses other functions to help generate it. Thanks for any help.
ImageView imageView = (ImageView) rootView.findViewById(R.id.qrCode);
try {
Bitmap bitmap = encodeAsBitmap(STR);
imageView.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
You can use the Handler
class from the android.os for periodic updates on whatever.
Example code here:
final Handler refreshHandler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
// do updates for imageview
refreshHandler.postDelayed(this, 30 * 1000);
}
};
refreshHandler.postDelayed(runnable, 30 * 1000);