After Android-Studio
warned me that there is too much load on the main thread.
Skipped 113 frames: the application may be doing too much work on its main thread
I have created a runnable to launch a thread with some processes:
new Thread(new Runnable() {
@Override
public void run() {
UpdateUI(); //Actualiza datos de la Interfaz de usuario
}
}
But it returns the error:
Only the original thread that created a view of the hierarchy can touch its views.
I searched for SO and can throw a thread
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//Cambiar controles
}
});
But since I have to do a lot of checks or a thread is executed at the same time, it returns the main thread overload. I even notice that the side menu slows down when closing.
How do you make a thread but be able to access the elements of the interface in order to modify your data or states?