onServicesDiscovered(BluetoothGatt gatt, int status) 永远不会被调用

2023-12-08

我有一个从 IntentService 调用的 BluetoothLeService。 BLEService 在连接之前工作正常。与 iBeacon 建立连接后,它调用 ;

public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                intentAction = ACTION_GATT_CONNECTED;
                mConnectionState = STATE_CONNECTED;
                broadcastUpdate(intentAction);
                Log.i(TAG, "Connected to GATT server.");
                // Attempts to discover services after successful connection.
                Log.i(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                intentAction = ACTION_GATT_DISCONNECTED;
                mConnectionState = STATE_DISCONNECTED;
                Log.i(TAG, "Disconnected from GATT server.");
                broadcastUpdate(intentAction);
            }
        }

到目前为止一切都很好,但在那之后,尽管 mBluetoothGatt.discoverServices() 返回 true,但 onServicesDiscovered(BluetoothGatt gatt, int status) 永远不会被调用。

- - - - - - - - - - -更新 - - - - - - - - - - - - - - ------

在调试时,它显示 newState == BluetoothProfile.STATE_CONNECTED 但它并没有真正连接。对于属于不存在设备的假 ID,它显示相同的结果。

-------------------------------------------------- ------------

这是我的回调

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                intentAction = ACTION_GATT_CONNECTED;
                mConnectionState = STATE_CONNECTED;
                broadcastUpdate(intentAction);
                Log.i(TAG, "Connected to GATT server.");
                // Attempts to discover services after successful connection.
                Log.i(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                intentAction = ACTION_GATT_DISCONNECTED;
                mConnectionState = STATE_DISCONNECTED;
                Log.i(TAG, "Disconnected from GATT server.");
                broadcastUpdate(intentAction);
            }
        }
        @Override
        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
            } else {
                Log.w(TAG, "onServicesDiscovered received: " + status);
            }
        }
        @Override
        public void onCharacteristicRead(BluetoothGatt gatt,
                                         BluetoothGattCharacteristic characteristic,
                                         int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            }
        }
        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt,
                                            BluetoothGattCharacteristic characteristic) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }
    };

我的广播接收器

 // Handles various events fired by the Service.
        // ACTION_GATT_CONNECTED: connected to a GATT server.
        // ACTION_GATT_DISCONNECTED: disconnected from a GATT server.
        // ACTION_GATT_SERVICES_DISCOVERED: discovered GATT services.
        // ACTION_DATA_AVAILABLE: received data from the device.  This can be a result of read
        //                        or notification operations.
        private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                final String action = intent.getAction();
                if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {


                } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {

                } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
                    // Show all the supported services and characteristics on the user interface.
                    mBluetoothLeService.getbattery();
                } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
                    batteryLevels.add(Double.valueOf(intent.getStringExtra(BluetoothLeService.EXTRAS_DEVICE_BATTERY)));
                }


            }
        };

    private static IntentFilter makeGattUpdateIntentFilter() {
        final IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
        intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
        intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
        intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
        return intentFilter;
    }

我的BluetoothLeService 课程

        import android.app.Service;
        import android.bluetooth.BluetoothAdapter;
        import android.bluetooth.BluetoothDevice;
        import android.bluetooth.BluetoothGatt;
        import android.bluetooth.BluetoothGattCallback;
        import android.bluetooth.BluetoothGattCharacteristic;
        import android.bluetooth.BluetoothGattDescriptor;
        import android.bluetooth.BluetoothGattService;
        import android.bluetooth.BluetoothManager;
        import android.bluetooth.BluetoothProfile;
        import android.content.Context;
        import android.content.Intent;
        import android.os.Binder;
        import android.os.IBinder;
        import android.util.Log;

        import java.util.Iterator;
        import java.util.List;
        import java.util.Set;
        import java.util.UUID;

/**
 * Service for managing connection and data communication with a GATT server hosted on a
 * given Bluetooth LE device.
 */
public class BluetoothLeService extends Service {
    private final static String TAG = BluetoothLeService.class.getSimpleName();

    private BluetoothManager mBluetoothManager;
    private BluetoothAdapter mBluetoothAdapter;
    private String mBluetoothDeviceAddress;
    private BluetoothGatt mBluetoothGatt;
    private int mConnectionState = STATE_DISCONNECTED;

    private static final int STATE_DISCONNECTED = 0;
    private static final int STATE_CONNECTING = 1;
    private static final int STATE_CONNECTED = 2;

    public final static String ACTION_GATT_CONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
    public final static String ACTION_GATT_DISCONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
    public final static String ACTION_GATT_SERVICES_DISCOVERED =
            "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
    public final static String ACTION_DATA_AVAILABLE =
            "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
    public final static String EXTRA_DATA =
            "com.example.bluetooth.le.EXTRA_DATA";
    public final static String EXTRAS_DEVICE_BATTERY = "EXTRAS_DEVICE_BATTERY";

    public final static UUID UUID_HEART_RATE_MEASUREMENT =
            UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);

    private static final UUID Battery_Service_UUID = UUID.fromString("0000180F-0000-1000-8000-00805f9b34fb");
    private static final UUID Battery_Level_UUID = UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb");


    // Implements callback methods for GATT events that the app cares about.  For example,
    // connection change and services discovered.
    private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                intentAction = ACTION_GATT_CONNECTED;
                mConnectionState = STATE_CONNECTED;
                broadcastUpdate(intentAction);
                Log.i(TAG, "Connected to GATT server.");
                // Attempts to discover services after successful connection.
                Log.i(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                intentAction = ACTION_GATT_DISCONNECTED;
                mConnectionState = STATE_DISCONNECTED;
                Log.i(TAG, "Disconnected from GATT server.");
                broadcastUpdate(intentAction);
            }
        }
        @Override
        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
            } else {
                Log.w(TAG, "onServicesDiscovered received: " + status);
            }
        }
        @Override
        public void onCharacteristicRead(BluetoothGatt gatt,
                                         BluetoothGattCharacteristic characteristic,
                                         int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            }
        }
        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt,
                                            BluetoothGattCharacteristic characteristic) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }
    };

    private void broadcastUpdate(final String action) {
        final Intent intent = new Intent(action);
        sendBroadcast(intent);
    }

    private void broadcastUpdate(final String action,
                                 final BluetoothGattCharacteristic characteristic) {

        final Intent intent = new Intent(action);
        Log.v(TAG, "characteristic.getStringValue(0) = " + characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0));
        intent.putExtra(EXTRAS_DEVICE_BATTERY, characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0));
        sendBroadcast(intent);
    }

    public class LocalBinder extends Binder {
        BluetoothLeService getService() {
            return BluetoothLeService.this;
        }
    }

    public void getbattery() {

        Set pairedDevices = mBluetoothAdapter.getBondedDevices();
        BluetoothGattService batteryService = mBluetoothGatt.getService(Battery_Service_UUID);

        List<BluetoothGattService> servicesList;
        servicesList = getSupportedGattServices();
        Iterator<BluetoothGattService> iter = servicesList.iterator();
        while (iter.hasNext()) {
            BluetoothGattService bService = (BluetoothGattService) iter.next();
            if (bService.getUuid().toString().equals(Battery_Level_UUID)){
                batteryService = bService;
            }
        }
        if(batteryService == null) {
            Log.d(TAG, "Battery service not found!");
            return;
        }


        BluetoothGattCharacteristic batteryLevel = batteryService.getCharacteristic(Battery_Level_UUID);
        if(batteryLevel == null) {
            Log.d(TAG, "Battery level not found!");
            return;
        }
        mBluetoothGatt.readCharacteristic(batteryLevel);
        Log.v(TAG, "batteryLevel = " + mBluetoothGatt.readCharacteristic(batteryLevel));
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        // After using a given device, you should make sure that BluetoothGatt.close() is called
        // such that resources are cleaned up properly.  In this particular example, close() is
        // invoked when the UI is disconnected from the Service.
        close();
        return super.onUnbind(intent);
    }

    private final IBinder mBinder = new LocalBinder();

    /**
     * Initializes a reference to the local Bluetooth adapter.
     *
     * @return Return true if the initialization is successful.
     */
    public boolean initialize() {
        // For API level 18 and above, get a reference to BluetoothAdapter through
        // BluetoothManager.
        if (mBluetoothManager == null) {
            mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
            if (mBluetoothManager == null) {
                Log.e(TAG, "Unable to initialize BluetoothManager.");
                return false;
            }
        }

        mBluetoothAdapter = mBluetoothManager.getAdapter();
        if (mBluetoothAdapter == null) {
            Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
            return false;
        }

        return true;
    }

    /**
     * Connects to the GATT server hosted on the Bluetooth LE device.
     *
     * @param address The device address of the destination device.
     *
     * @return Return true if the connection is initiated successfully. The connection result
     *         is reported asynchronously through the
     *         {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
     *         callback.
     */
    public boolean connect(final String address) {
        if (mBluetoothAdapter == null || address == null) {
            Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
            return false;
        }
        // Previously connected device.  Try to reconnect.
        if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
                && mBluetoothGatt != null) {
            Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
            if (mBluetoothGatt.connect()) {
                mConnectionState = STATE_CONNECTING;
                return true;
            } else {
                return false;
            }
        }
        final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
        if (device == null) {
            Log.w(TAG, "Device not found.  Unable to connect.");
            return false;
        }
        // We want to directly connect to the device, so we are setting the autoConnect
        // parameter to false.
        mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
        Log.d(TAG, "Trying to create a new connection.");
        mBluetoothDeviceAddress = address;
        mConnectionState = STATE_CONNECTING;
        return true;
    }

    /**
     * Disconnects an existing connection or cancel a pending connection. The disconnection result
     * is reported asynchronously through the
     * {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
     * callback.
     */
    public void disconnect() {
        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
            Log.w(TAG, "BluetoothAdapter not initialized");
            return;
        }
        mBluetoothGatt.close();
    }

    /**
     * After using a given BLE device, the app must call this method to ensure resources are
     * released properly.
     */
    public void close() {
        if (mBluetoothGatt == null) {
            return;
        }
        mBluetoothGatt.close();
        mBluetoothGatt = null;
    }

    /**
     * Request a read on a given {@code BluetoothGattCharacteristic}. The read result is reported
     * asynchronously through the {@code BluetoothGattCallback#onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)}
     * callback.
     *
     * @param characteristic The characteristic to read from.
     */
    public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
            Log.w(TAG, "BluetoothAdapter not initialized");
            return;
        }
        mBluetoothGatt.readCharacteristic(characteristic);
    }

    public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {

        if(status == BluetoothGatt.GATT_SUCCESS) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }
    }

    /**
     * Enables or disables notification on a give characteristic.
     *
     * @param characteristic Characteristic to act on.
     * @param enabled If true, enable notification.  False otherwise.*/

    public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
                                              boolean enabled) {
        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
            Log.w(TAG, "BluetoothAdapter not initialized");
            return;
        }
        mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);

        // This is specific to Heart Rate Measurement.
        if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                    UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mBluetoothGatt.writeDescriptor(descriptor);
        }
        if (Battery_Level_UUID.equals(characteristic.getUuid())) {
            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                    UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mBluetoothGatt.writeDescriptor(descriptor);
        }
    }

    /**
     * Retrieves a list of supported GATT services on the connected device. This should be
     * invoked only after {@code BluetoothGatt#discoverServices()} completes successfully.
     *
     * @return A {@code List} of supported services.
     */
    public List<BluetoothGattService> getSupportedGattServices() {
        if (mBluetoothGatt == null) return null;

        return mBluetoothGatt.getServices();
    }
}

我想到了。真正的问题是连接。它显示它已连接,但实际上没有,我尝试使用错误地址连接,但它仍然连接。

我添加后

mBluetoothGatt.connect();

在BluetoothLeService.java的connect方法结束时它开始工作。

感谢您的帮助维克拉姆·埃日尔

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

onServicesDiscovered(BluetoothGatt gatt, int status) 永远不会被调用 的相关文章

  • 您的应用中的 Google Analytics SDK

    我按照这里的说明进行操作 https developers google com analytics devguides collection android v3 https developers google com analytics
  • 如何用Android做交互动画(翻译)

    我在 Android 中有一些 png 序列 我需要将它们的 x 和 y 位置从屏幕顶部到底部的翻译动画化 当动画发生时 我需要对象来接收单击事件 我知道这在 3 0 之前的 Android 版本中效果不太好 因为display对象的位置与
  • 如何在Android上获取当前播放曲目的路径[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我想编写一个应用程序将当前播放的音乐流式传输到另一台设备 两个设备之间的连接确实有效 我还可以通过 wifi 传输一些字符串 但在获取
  • Android Widget ID 是否持久

    在从桌面删除该 Widget 实例之前 您从操作系统收到的用户桌面上特定 Widget 实例的 Widget ID 是否一致 我找不到任何明确说明这一点的文档 但我假设这是因为文档说您可以使用小部件 id 来存储任何实例配置信息 我想将一些
  • 需要对某些片段禁用 CollapsingToolbarLayout 的展开

    我有一个AppCompatActivity控制替换许多片段 这是我的布局 活动 main xml
  • 如何使用具有三种布局的视图翻转器?

    我目前正在使用ViewFlipper我的主要活动有两种不同的布局 我想使用第三种布局 但我只能找到showNext and showPrevious 命令 有人可以告诉我如何使用来实现第三种布局吗ViewFlipper 为您制作了一个示例
  • 清晰的图标 清晰的 Android 应用程序

    你好 下午好 关于如何提高图标的 png 质量 有什么想法吗 我使用了 Android 开发者页面上的套件 但我无法获得清晰的图像 我的意思是非常清晰 我是否需要以不同的方式加载此图标 而不仅仅是拖入我的布局 谢谢 我使用这个布局
  • 如何使用retrofit2动态设置超时?

    public class Router private static Retrofit retrofit null public Retrofit getRetrofit if retrofit null OkHttpClient clie
  • Android 中图像字节表示的每像素字节数

    我目前正在编写一个Android应用程序 需要在其中使用OCR 为了实现这一点 我将 Tesseract 与tesseract android tools 项目 http code google com p tesseract androi
  • 如何在 Android 中创建始终位于顶部的全屏覆盖 Activity

    我希望能够创建一个始终位于 Android 显示前面的 Activity 它不应该接收任何输入 只需将其传递到其下面的任何应用程序即可 像平视显示器之类的东西 我能够研究我需要将底层窗口类型设置为 TYPE SYSTEM ALERT 但看起
  • 将清除会话标志设置为 FALSE 后,我丢失了已发布的值

    有人有一个合乎逻辑的解释为什么尽管我有clear session flage false当我未连接到经纪商时 我没有收到我订阅的更新的已发布消息 将 aore提到的标志设置为 false 后 我运行了我的应用程序 并且我不断向主题发布一些值
  • 构建应用程序时出现 BufferOverflowException

    每次我想运行我的 Android 应用程序时 我都会收到错误 2013 11 02 13 05 36 Dex Loader Unable to execute dex java nio BufferOverflowException Che
  • Android - 使用 SAX 解析器解析大文件

    我正在尝试使用 SAX 解析器解析来自 webservice 的 xml 数据 当我尝试使用 URL 解析数据 大小 7 4MB 时 它工作正常 但是当我从 URL 复制 xml 数据并放置 xml 文件时 size 7 4MB 在raw文
  • MutableStateflow 值、更新、发出

    假设我有一个可变状态流 https kotlin github io kotlinx coroutines kotlinx coroutines core kotlinx coroutines flow mutable state flow
  • 如何防止应用程序被盗(针对Android应用程序)?

    我想知道防止人们窃取我的应用程序的最有效方法是什么 在线下载 apk 的副本而不是购买它 我已经花了一个lot特别是 Droidbox 上的时间 并且不会发布 Sync 直到我可以保证提供专业版本的非法副本的人无法发布 有人实施过这个吗 我
  • 使用 Box2d(适用于 Android)进行碰撞检测?

    有人可以解释一下使用 box2d for android 进行碰撞检测的工作原理吗 我无法理解 BBContactListener 以什么方式工作 BBContactListener listener new BBContactListen
  • Android - 检测视图上的双击和三次点击

    我一直在尝试构建一个可以检测双敲击和三敲击的敲击检测器 在我的努力失败后 我在网上搜索了很长时间以找到可以使用的东西 但没有运气 奇怪的是 像这样的图书馆如此稀缺 有什么帮助吗 你可以尝试这样的事情 尽管我通常建议不要使用三次点击作为一种模
  • Android:选择 EditField 上焦点上的所有文本

    我试图让 Android 在获得焦点时选择 EditText 字段中的所有文本 我在布局中使用此属性 在两个字段上 android selectAllOnFocus true 我不确定这是否相关 但为了将光标移动到第一个可编辑字段 前面 还
  • 在 VideoView 开始播放之前,TextView 不会显示

    我编写了一个android应用程序 它有两个视图 TextView上方的VideoView 位于ScrollView内部 我遇到了一个问题 直到VideoView开始播放视频 TextView才显示 并且我有一个黑屏 这可能需要很长一段时间
  • 将主题应用到 v7 支持操作栏

    我正在使用support v7库来实现ActionBar在我的应用程序中 我的styles xml file

随机推荐

  • React 事件处理函数无需使用 bind() 即可工作

    我正在学习 React 并且遇到了事件处理程序 在React中 建议将函数绑定到this 然后将其用作事件处理程序 但是 我没有绑定它 但仍然得到所需的输出 下面是我的代码 import React Component from react
  • 使用 Java 卡钱包

    我是一个java卡初学者 从示例中复制了下面的代码 不知何故 我已经知道部分代码是如何工作的 但还是对下面的事情感到困惑 ownerpin 的工作方式以及设置 pin 的方式和时间 如何进行信用和借记工作 我了解平衡是如何运作的 这方面还不
  • 如何在一个应用程序中获取多个图标来启动不同的活动?

    我有一个包含两个活动的应用程序 我希望能够在启动器中显示两个图标 每个图标在应用程序中启动相应的活动 具体来说 我想要一个图标来启动我的主应用程序 另一个图标来启动我的设置活动 这可能吗 这是我到目前为止所尝试过的
  • 复制到输出目录复制文件夹结构但只想复制文件

    我有一个 VS2008 我想将某些文件从目录复制到我的 bin 文件夹 我已经设置了文件 位于 common browserhawk 到 复制到输出目录 但是 它也会复制文件夹结构 文件被复制到 bin common browserhawk
  • 如何对重复标签进行分组,以便在 Chart.js 中创建没有重复的标签

    我似乎无法解决这个问题 我的唱片公司给我发回列表 在我的例子中 我希望只有 HOME40 HOME60 和 PRO 作为标签 但不幸的是它返回了它们的串联 我还想改变颜色 如果产品是HOME40那么颜色必须是绿色 如果是PRO那么颜色必须是
  • java中字节数组到短数组然后再返回

    我在获取存储在字节数组中的音频数据 将其转换为大端短数组 对其进行编码 然后将其更改回字节数组时遇到一些问题 这是我所拥有的 原始音频数据存储在audioBytes2中 我使用相同的格式进行解码 并在 cos 函数上加上减号 不幸的是 更改
  • Gmail 5.0 应用在收到 ACTION_SEND 意图时失败,并显示“附件权限被拒绝”

    我的应用程序创建带有附件的邮件 并使用意图Intent ACTION SEND启动邮件应用程序 它适用于我测试过的所有邮件应用程序 但新的 Gmail 5 0 它适用于 Gmail 4 9 除外 邮件在没有附件的情况下打开 显示错误 附件的
  • 在 Angular/JHipster 应用程序上使用另一个模块的组件

    我正在尝试使用component来自另一个module on an 角5生成的应用程序jhipster When a module其中包含component我想使用的是导入的route of the module发生导入的地方被覆盖rout
  • 在 Woocommerce 中下订单后,将附件添加到管理员电子邮件通知

    下新订单后 我尝试向商店管理员发送 PDF 文件 问题与woocommerce email attachments重点是电子邮件会同时发送给客户和管理员 add filter woocommerce email attachments at
  • 符合 MVC 4 站点 508

    我花了很多时间研究这个 但也许有人指出了我正确的方向 需要构建一个符合 508 标准的 MVC 4 网站 三年前我做了一些 508 合规性测试和标签插入 但我真的想再做一次 其他人用什么 寻找什么标签 什么测试工具 有免费的测试工具吗 AJ
  • iOS 登录/注销在 Swift 中的实现

    我一直在尝试快速实现 iOS 应用程序的登录 注销流程 这是我的故事板 在主视图控制器 即蓝屏 中 我实现了以下代码来检测用户是否已登录 然后自动将它们带到表视图控制器 覆盖 func viewDidAppear animated Bool
  • 作为文本框的 AutoCompleteCustomSource 的列表框项目

    我已使用数据源属性将一些项目填充到列表框中 现在我需要从列表框中列出的项目中为文本框设置 AutoCompleteCustomSource 准确地说 ListBox 的 DataSource 和 textBox 的 AutoComplete
  • 将 R 对象分组到列表中

    我已将一系列 SpatialPolygonsDataFrames 加载到我的工作区中 每个命名对象都有一个 adm0 adm1 or adm2 附有国家缩写 对于德国来说 这看起来像 DEU adm0 DEU adm1 and DEU ad
  • 用于检查 perl 模块是否已安装的 perl 脚本

    我希望能够对列表中的每个模块运行此测试 不知道如何 ger perl 循环遍历每个项目 use Module Load eval load Image Magick 1 or die you need Module to run this
  • LDAP Bind 似乎返回 true,密码为空

    我有这段代码根据 LDAP 目录对我的用户进行身份验证 当密码不正确时 它返回 false 但如果密码留空 它仍然会对用户进行身份验证 有什么想法可能会发生这种情况吗 if ldap bind ds user dn password sha
  • C 结构体顺序有任何保证吗?

    我广泛使用了结构 并且看到了一些有趣的东西 特别是 value代替value gt first value其中 value 是指向结构体的指针 first value是第一个成员 是 value safe 另请注意 由于对齐 无法保证大小
  • 使用 WPF 应用程序连接到数据库

    我不久前开始接触 WPF 由于我正处于学习 MVVM 的阶段 所以我正在使用THIS教程 继该教程之后 我现在有了一个涉及产品的基本项目 我想做的下一件事是了解如何连接到数据库并从中存储 检索信息 我的问题是 连接数据库的可用方法有哪些 最
  • 有没有办法检测用户何时更改了设备上的时钟时间?

    有没有办法检测Android系统时钟何时被重置由用户在安卓中 我正在设计一个应用程序 它使用系统时间来确定用户何时在特定时间位于特定地点 并且我不想依赖当时的网络可用性 显然 因此最好知道用户何时更改了系统时钟 这样他们就无法 作弊 就在这
  • 或 RequestDispatcher.forward 使用 GET 或 POST 吗?

    问题如标题所示
  • onServicesDiscovered(BluetoothGatt gatt, int status) 永远不会被调用

    我有一个从 IntentService 调用的 BluetoothLeService BLEService 在连接之前工作正常 与 iBeacon 建立连接后 它调用 public void onConnectionStateChange