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