So I have a problem with an Android App I'm giving maintenance they have a callBack on the app that is trigger when something happens, and there is a runOnUiThread. However it seems not to be working but. When I minimize the app and I resume it... It shows the changes. (I have already tried the invalidate and postInvalidate... The only command that seems to work it's recreate, but it shows a black screen and the reloads the app, I don't want that to happen)
private ServiceCallback<ProductIntoItem> getInfoCallback = new ServiceCallback<ProductIntoItem>() {
@Override
public void onSuccess(final ProductIntoItem productIntoItem) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Tag tag = new Tag("", epcReadings.get(0));
tabLayout.addTab(tabLayout.newTab().setText("info item"));
tabLayout.addTab(tabLayout.newTab().setText("info sku"));
tabLayout.setOnTabSelectedListener(InfoProductActivity.this);
infoItemFragment = InfoItemFragment.newInstance(productIntoItem, location, tag.getSku());
infoSkuFragment = InfoSkuFragment.newInstance(productIntoItem, location, tag.getSku());
initWithFragment(R.id.container_tabs_info, infoItemFragment);
recreate();
}
});
}
@Override
public void onFailure(NetworkException e) {
}
};
Edit
The callback is called from this section of the code: (The onTagRead method is native from a device that's bluetooth connected. This is all inside the Running Activity class)
@Override
public void onTagRead(String epc) {
if (epc != null) {
rfIdManager.stopTagReading();
epcReadings.add(epc);
}
if (epcReadings.size() >= 1 && epcReadings.size() < 2 && isNetworkConnectionAvailable()) {
network.getInfoItem(epcReadings.get(0), getInfoCallback);
}
}