+ /**
+ * Show error message
+ *
+ * @param result Result with the failure information.
+ */
+ public void showErrorMessage(final RemoteOperationResult result) {
+ Handler handler = new Handler(Looper.getMainLooper());
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ // The Toast must be shown in the main thread to grant that will be hidden correctly; otherwise
+ // the thread may die before, an exception will occur, and the message will be left on the screen
+ // until the app dies
+ Toast.makeText(
+ getContext().getApplicationContext(),
+ ErrorMessageAdapter.getErrorCauseMessage(
+ result,
+ null,
+ getContext().getResources()
+ ),
+ Toast.LENGTH_SHORT
+ ).show();
+ }
+ });
+ }
+