Example usage for android.os RemoteException RemoteException

List of usage examples for android.os RemoteException RemoteException

Introduction

In this page you can find the example usage for android.os RemoteException RemoteException.

Prototype

public RemoteException(String message) 

Source Link

Usage

From source file:org.anhonesteffort.flock.ExportService.java

private void handleStartExport() {
    Log.d(TAG, "HANDLE START EXPORT");
    handleInitializeNotification();//  ww w .  ja v a2  s  .c o m

    try {
        Optional<DavAccount> account = DavAccountHelper.getAccount(getBaseContext());
        ContentProviderClient contactClient = getBaseContext().getContentResolver()
                .acquireContentProviderClient(AddressbookSyncScheduler.CONTENT_AUTHORITY);
        ContentProviderClient calendarClient = getBaseContext().getContentResolver()
                .acquireContentProviderClient(CalendarsSyncScheduler.CONTENT_AUTHORITY);

        if (account.isPresent()) {
            try {

                Optional<LocalContactCollection> addressbook = getAddressbook(contactClient, account.get());
                List<LocalEventCollection> calendars = getCalendars(calendarClient,
                        account.get().getOsAccount());
                List<AbstractLocalComponentCollection<?>> collections = new LinkedList<>();

                if (!addressbook.isPresent()) {
                    throw new RemoteException("addressbook missing, what is going on?");
                }

                collections.add(addressbook.get());
                collections.addAll(calendars);
                List<File> outputFiles = createFilesForCollections(collections);

                if (isStorageSpaceAvailable(collections, outputFiles)) {
                    File contactsFile = outputFiles.remove(0);
                    handleExportContacts(addressbook.get(), contactsFile);
                    handleExportCalendars(calendars, outputFiles);
                    outputFiles.add(contactsFile);
                    handleIndexFilesWithMediaScanner(outputFiles);
                    handleExportComplete(EndState.SUCCESS);
                    return;
                } else {
                    handleExportComplete(EndState.PROMPT_MAKE_SPACE);
                    return;
                }

            } catch (ValidationException e) {
                Log.e(TAG, "WTF ical4j", e);
            } catch (RemoteException e) {
                Log.e(TAG, "why android?", e);
            } catch (IOException e) {
                Log.e(TAG, "why android?", e);
            }
        } else {
            handleExportComplete(EndState.PROMPT_LOGIN);
            return;
        }
    } catch (Exception e) {
        Log.e(TAG, "caught unexpected runtime exception", e);
    }

    handleExportComplete(EndState.PROMPT_RESTART);
}