@@ -310,35 +310,48 @@ public void run() {
310310 binding .checkForUpdate .setOnClickListener (
311311 view -> {
312312 Toast .makeText (this , "Checking for updates..." , Toast .LENGTH_SHORT ).show ();
313- Sentry .distribution ()
314- .checkForUpdate (
315- result -> {
316- runOnUiThread (
317- () -> {
318- String message ;
319- if (result instanceof UpdateStatus .NewRelease ) {
320- UpdateStatus .NewRelease newRelease = (UpdateStatus .NewRelease ) result ;
321- message =
322- "Update available: "
323- + newRelease .getInfo ().getBuildVersion ()
324- + " (Build "
325- + newRelease .getInfo ().getBuildNumber ()
326- + ")\n Download URL: "
327- + newRelease .getInfo ().getDownloadUrl ();
328- } else if (result instanceof UpdateStatus .UpToDate ) {
329- message = "App is up to date!" ;
330- } else if (result instanceof UpdateStatus .NoNetwork ) {
331- UpdateStatus .NoNetwork noNetwork = (UpdateStatus .NoNetwork ) result ;
332- message = "No network connection: " + noNetwork .getMessage ();
333- } else if (result instanceof UpdateStatus .UpdateError ) {
334- UpdateStatus .UpdateError error = (UpdateStatus .UpdateError ) result ;
335- message = "Error checking for updates: " + error .getMessage ();
336- } else {
337- message = "Unknown status" ;
338- }
339- Toast .makeText (this , message , Toast .LENGTH_LONG ).show ();
340- });
341- });
313+ java .util .concurrent .Future <UpdateStatus > future = Sentry .distribution ().checkForUpdate ();
314+ // Process result on background thread, then update UI
315+ new Thread (
316+ () -> {
317+ try {
318+ UpdateStatus result = future .get ();
319+ runOnUiThread (
320+ () -> {
321+ String message ;
322+ if (result instanceof UpdateStatus .NewRelease ) {
323+ UpdateStatus .NewRelease newRelease = (UpdateStatus .NewRelease ) result ;
324+ message =
325+ "Update available: "
326+ + newRelease .getInfo ().getBuildVersion ()
327+ + " (Build "
328+ + newRelease .getInfo ().getBuildNumber ()
329+ + ")\n Download URL: "
330+ + newRelease .getInfo ().getDownloadUrl ();
331+ } else if (result instanceof UpdateStatus .UpToDate ) {
332+ message = "App is up to date!" ;
333+ } else if (result instanceof UpdateStatus .NoNetwork ) {
334+ UpdateStatus .NoNetwork noNetwork = (UpdateStatus .NoNetwork ) result ;
335+ message = "No network connection: " + noNetwork .getMessage ();
336+ } else if (result instanceof UpdateStatus .UpdateError ) {
337+ UpdateStatus .UpdateError error = (UpdateStatus .UpdateError ) result ;
338+ message = "Error checking for updates: " + error .getMessage ();
339+ } else {
340+ message = "Unknown status" ;
341+ }
342+ Toast .makeText (this , message , Toast .LENGTH_LONG ).show ();
343+ });
344+ } catch (Exception e ) {
345+ runOnUiThread (
346+ () ->
347+ Toast .makeText (
348+ this ,
349+ "Error checking for updates: " + e .getMessage (),
350+ Toast .LENGTH_LONG )
351+ .show ());
352+ }
353+ })
354+ .start ();
342355 });
343356
344357 binding .openCameraActivity .setOnClickListener (
0 commit comments