I have a WHILE loop that exits when run on one phone, yet on a different phone it doesn't!
In my class I declare the following variable
Then in my onCreateView I have the following with logging
The reason for the while loop is to stop the code until a different class GetNotificationsNewMySQL has been called, and in this class I set notificationsExtracted = true, as shown in the following piece of code
Now when I run it on all the phones except one (a Conexis x2), it logs that notificationsExtracted has been set to true, it never seems to register this state where the class was called from. Note that when first instantiating the class, it first sets notificationsExtracted = false, does some work, and then sets it true, hence the 2nd logging line "notificationExtracted = false"
This is my logging output (where it works as expected)
The above shows that the while loop waits until the variable gets set to true before continuing the flow of code (i.e. when it logs "4" it has then continued).
However, on this one particular phone, it will log the exact same first 3 lines, i.e. in the called class it logs the variable as being true, but it never exits the while loop, with the result that the 4th line (the "4") never gets logged, and the phone then hangs.
Very perplexing, and I hope someone can shed some light on this please
In my class I declare the following variable
Code:
public class FragmentMain extends Fragment {
private Boolean notificationsExtracted;
...
Then in my onCreateView I have the following with logging
Code:
...
Log.i("notif", "3");
GetNotificationsNewMySQL getNotificationsNewMySQL = new GetNotificationsNewMySQL();
getNotificationsNewMySQL.execute("");
while (!notificationsExtracted) {};
Log.i("notif", "4");
...
The reason for the while loop is to stop the code until a different class GetNotificationsNewMySQL has been called, and in this class I set notificationsExtracted = true, as shown in the following piece of code
Code:
notificationsExtracted = true;
if (notificationsExtracted)
Log.i("notif", "true");
else
Log.i("notif", "false");
Now when I run it on all the phones except one (a Conexis x2), it logs that notificationsExtracted has been set to true, it never seems to register this state where the class was called from. Note that when first instantiating the class, it first sets notificationsExtracted = false, does some work, and then sets it true, hence the 2nd logging line "notificationExtracted = false"
This is my logging output (where it works as expected)
2019-11-13 16:34:04.156 12400-12400/com.example.pdcapp I/notif: 3
2019-11-13 16:34:04.156 12400-12400/com.example.pdcapp I/notif: notificationExtracted = false
2019-11-13 16:34:04.261 12400-12435/com.example.pdcapp I/notif: true
2019-11-13 16:34:04.261 12400-12400/com.example.pdcapp I/notif: 4
The above shows that the while loop waits until the variable gets set to true before continuing the flow of code (i.e. when it logs "4" it has then continued).
However, on this one particular phone, it will log the exact same first 3 lines, i.e. in the called class it logs the variable as being true, but it never exits the while loop, with the result that the 4th line (the "4") never gets logged, and the phone then hangs.
Very perplexing, and I hope someone can shed some light on this please