Example usage for android.bluetooth.le AdvertiseCallback ADVERTISE_FAILED_FEATURE_UNSUPPORTED

List of usage examples for android.bluetooth.le AdvertiseCallback ADVERTISE_FAILED_FEATURE_UNSUPPORTED

Introduction

In this page you can find the example usage for android.bluetooth.le AdvertiseCallback ADVERTISE_FAILED_FEATURE_UNSUPPORTED.

Prototype

int ADVERTISE_FAILED_FEATURE_UNSUPPORTED

To view the source code for android.bluetooth.le AdvertiseCallback ADVERTISE_FAILED_FEATURE_UNSUPPORTED.

Click Source Link

Document

This feature is not supported on this platform.

Usage

From source file:com.android.bleserver.AdvertiserFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    advertisingFailureReceiver = new BroadcastReceiver() {

        /**/*from ww w .  j ava  2 s.com*/
         * Receives Advertising error codes from {@code AdvertiserService} and displays error messages
         * to the user. Sets the advertising toggle to 'false.'
         */
        @Override
        public void onReceive(Context context, Intent intent) {

            int errorCode = intent.getIntExtra(AdvertiserService.ADVERTISING_FAILED_EXTRA_CODE, -1);

            mSwitch.setChecked(false);

            String errorMessage = getString(R.string.start_error_prefix);
            switch (errorCode) {
            case AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED:
                errorMessage += " " + getString(R.string.start_error_already_started);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE:
                errorMessage += " " + getString(R.string.start_error_too_large);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED:
                errorMessage += " " + getString(R.string.start_error_unsupported);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR:
                errorMessage += " " + getString(R.string.start_error_internal);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:
                errorMessage += " " + getString(R.string.start_error_too_many);
                break;
            case AdvertiserService.ADVERTISING_TIMED_OUT:
                errorMessage = " " + getString(R.string.advertising_timedout);
                break;
            default:
                errorMessage += " " + getString(R.string.start_error_unknown);
            }

            Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
        }
    };
}

From source file:sample.hawk.com.mybasicappcomponents.hardware.bt_advertisements.BLE_AdvertiserFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    advertisingFailureReceiver = new BroadcastReceiver() {

        /**/*from   w  w  w . j ava  2 s. c  om*/
         * Receives Advertising error codes from {@code AdvertiserService} and displays error messages
         * to the user. Sets the advertising toggle to 'false.'
         */
        @Override
        public void onReceive(Context context, Intent intent) {

            int errorCode = intent.getIntExtra(BLE_AdvertiserService.ADVERTISING_FAILED_EXTRA_CODE, -1);

            mSwitch.setChecked(false);

            String errorMessage = getString(R.string.start_error_prefix);
            switch (errorCode) {
            case AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED:
                errorMessage += " " + getString(R.string.start_error_already_started);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE:
                errorMessage += " " + getString(R.string.start_error_too_large);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED:
                errorMessage += " " + getString(R.string.start_error_unsupported);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR:
                errorMessage += " " + getString(R.string.start_error_internal);
                break;
            case AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:
                errorMessage += " " + getString(R.string.start_error_too_many);
                break;
            case BLE_AdvertiserService.ADVERTISING_TIMED_OUT:
                errorMessage = " " + getString(R.string.advertising_timedout);
                break;
            default:
                errorMessage += " " + getString(R.string.start_error_unknown);
            }

            Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
        }
    };
}