Я не получаю никакого ответа от широковещательного приемника в приведенном ниже коде каждый раз, когда управление переходит к этому случаю с именем ACTION_NO_RESPONSE_FOUND_TERMINATE
.
Я подключаюсь через Bluetooth, получая этот ответ.
private BroadcastReceiver mBroadCastReciever = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equalsIgnoreCase(BleService.SAMPLE_RESPONSE_FOUND)) {
Toast.makeText(LightConfigurationActivity.this, "Response found is : "+intent.getStringExtra(BleService.COMMAND_RESPONSE), Toast.LENGTH_SHORT).show();
}
switch (action) {
case BleService.ACTION_LAST_RESPONSE_FOUND:
if (mProgressDialog != null) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mProgressDialog.dismiss();
showSuccessPopUp();
}
},15000);
}
break;
case BleService.ACTION_CHECKSUM_MATCH_FAILED:
if (mIsActivityRunning) {
resendconfig();
}
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
break;
case BleService.ACTION_GAT_FAILED_TO_RECIEVE_ACKNOWLEDGMENT:
/**
* ToDo : Need to remove Toast notification.
*/
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
if (mIsActivityRunning) {
showAlertDialog(getString(R.string.failed_to_get_response_from_device));
}
break;
case BleService.ACTION_NO_RESPONSE_FOUND_TERMINATE:
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
//Toast.makeText(context, "Failed to get acknowledgment. Please try again...", Toast.LENGTH_SHORT).show();
break;
case BleService.ACTION_GATT_DISCONNECTED:
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
Toast.makeText(LightConfigurationActivity.this, R.string.disconnected, Toast.LENGTH_SHORT).show();
break;
}
}
};
От BleService, получающего ответ от намерения Action_no_response_found
BleService.java:
private void broadcastUpdate(String action, BluetoothDevice device, int rssi, byte[] scanRecord) {
Intent intent = new Intent(action);
intent.putExtra(EXTRA_DEVICE, device);
intent.putExtra(EXTRA_DATA, scanRecord);
sendBroadcast(intent);
}
private void broadcastUpdate(String action, String address, int status) {
Intent intent = new Intent(action);
intent.putExtra(EXTRA_ADDRESS, address);
intent.putExtra(EXTRA_STATUS, status);
sendBroadcast(intent);
}
private void broadcastUpdate(String action, String response) {
Intent intent = new Intent(action);
intent.putExtra(COMMAND_RESPONSE, response);
sendBroadcast(intent);
}
private void broadcastUpdate(String action) {
Intent intent = new Intent(action);
sendBroadcast(intent);
}