Android Open Source - GPSDataCollector Location Service Error Messages






From Project

Back to project page GPSDataCollector.

License

The source code is released under:

GNU General Public License

If you think the Android project GPSDataCollector listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2013 The Android Open Source Project
 *//from w  w w  .j  a  va2 s .  c o m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ymelo.gpsdatacollector.app;

import android.content.Context;
import android.content.res.Resources;
import com.google.android.gms.common.ConnectionResult;

/**
 * Map error codes to error messages.
 */
public class LocationServiceErrorMessages {

    // Don't allow instantiation
    private LocationServiceErrorMessages() {}

    public static String getErrorString(Context context, int errorCode) {

        // Get a handle to resources, to allow the method to retrieve messages.
        Resources mResources = context.getResources();

        // Define a string to contain the error message
        String errorString;

        // Decide which error message to get, based on the error code.
        switch (errorCode) {
            case ConnectionResult.DEVELOPER_ERROR:
                errorString = mResources.getString(R.string.connection_error_misconfigured);
                break;

            case ConnectionResult.INTERNAL_ERROR:
                errorString = mResources.getString(R.string.connection_error_internal);
                break;

            case ConnectionResult.INVALID_ACCOUNT:
                errorString = mResources.getString(R.string.connection_error_invalid_account);
                break;

            case ConnectionResult.LICENSE_CHECK_FAILED:
                errorString = mResources.getString(R.string.connection_error_license_check_failed);
                break;

            case ConnectionResult.NETWORK_ERROR:
                errorString = mResources.getString(R.string.connection_error_network);
                break;

            case ConnectionResult.RESOLUTION_REQUIRED:
                errorString = mResources.getString(R.string.connection_error_needs_resolution);
                break;

            case ConnectionResult.SERVICE_DISABLED:
                errorString = mResources.getString(R.string.connection_error_disabled);
                break;

            case ConnectionResult.SERVICE_INVALID:
                errorString = mResources.getString(R.string.connection_error_invalid);
                break;

            case ConnectionResult.SERVICE_MISSING:
                errorString = mResources.getString(R.string.connection_error_missing);
                break;

            case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
                errorString = mResources.getString(R.string.connection_error_outdated);
                break;

            case ConnectionResult.SIGN_IN_REQUIRED:
                errorString = mResources.getString(
                        R.string.connection_error_sign_in_required);
                break;

            default:
                errorString = mResources.getString(R.string.connection_error_unknown);
                break;
        }

        // Return the error message
        return errorString;
    }
}




Java Source Code List

com.ymelo.gpsdatacollector.app.ApplicationTest.java
com.ymelo.gpsdatacollector.app.Config.java
com.ymelo.gpsdatacollector.app.DisplayFragment.java
com.ymelo.gpsdatacollector.app.GetAddressTask.java
com.ymelo.gpsdatacollector.app.LocationServiceErrorMessages.java
com.ymelo.gpsdatacollector.app.MainActivity.java
com.ymelo.gpsdatacollector.app.MapFragment.java
com.ymelo.gpsdatacollector.app.NavigationDrawerFragment.java
com.ymelo.gpsdatacollector.app.RecordFragment.java
com.ymelo.gpsdatacollector.app.TaskUpdater.java
com.ymelo.gpsdatacollector.app.TripListFragment.java
com.ymelo.gpsdatacollector.app.utils.FileUtils.java
com.ymelo.gpsdatacollector.app.utils.FragmentFix.java
com.ymelo.gpsdatacollector.app.utils.LocationUtils.java