title: BLE advertisement with different data packets in android
body: <p>I am new in Bluetooth low energy advertisement. BLE supports dynamic advertisement from API level 28. as you can advertise different data packets. I am trying to do but getting status code 18 and Null in Advertising set. 
  Can anyone please tell me how can I do dynamic advertisement in android. My device is Nexus 6 with Android 8.1.0.</p>
  
  <p>here is my code : </p>
  
  <pre><code> //setting parameters
  
  AdvertisingSetParameters parameters = (new AdvertisingSetParameters.Builder())
              .setLegacyMode(false)
              .setConnectable(true)
              .setInterval(AdvertisingSetParameters.INTERVAL_HIGH)
              .setTxPowerLevel(AdvertisingSetParameters.TX_POWER_MEDIUM)
              .build();
  
  //Adding advertising data
  
  AdvertiseData.Builder mbuilder = new AdvertiseData.Builder();
      mbuilder.setIncludeDeviceName(false);
      mbuilder.setIncludeTxPowerLevel(false);
  
  mbuilder.addManufacturerData(Integer.parseInt(manuf, 16), manufacturerData1);
      AdvertiseData mData = mbuilder.build();
  
  //Adding scan response data
  
  AdvertiseData scanResponse = new AdvertiseData.Builder()
              .setIncludeDeviceName(true)
              .build();
  
  //Advertising set call back and I am receiving null in Advertising set and status code 18
  
  AdvertisingSetCallback callback = new AdvertisingSetCallback() {
          @Override
          public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) {
              Log.i("", "onAdvertisingSetStarted(): txPower:" + txPower + " , status: "
                      + status);
  
              if (status==AdvertisingSetCallback.ADVERTISE_FAILED_ALREADY_STARTED)
                  Toast.makeText(context, "ADVERTISE_FAILED_ALREADY_STARTED", Toast.LENGTH_SHORT).show();
              else if (status==AdvertisingSetCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED)
                  Toast.makeText(context, "ADVERTISE_FAILED_FEATURE_UNSUPPORTED", Toast.LENGTH_SHORT).show();
              else if (status==AdvertisingSetCallback.ADVERTISE_FAILED_DATA_TOO_LARGE)
                  Toast.makeText(context, "ADVERTISE_FAILED_DATA_TOO_LARGE", Toast.LENGTH_SHORT).show();
              else if (status==AdvertisingSetCallback.ADVERTISE_FAILED_INTERNAL_ERROR)
                  Toast.makeText(context, "ADVERTISE_FAILED_INTERNAL_ERROR", Toast.LENGTH_SHORT).show();
              else if (status==AdvertisingSetCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS)
                  Toast.makeText(context, "ADVERTISE_FAILED_TOO_MANY_ADVERTISERS", Toast.LENGTH_SHORT).show();
              else if (status==AdvertisingSetCallback.ADVERTISE_SUCCESS)
                  Toast.makeText(context, "ADVERTISE_SUCCESS", Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) {
              Log.i("", "onAdvertisingSetStopped():");
          }
      };
  
  //starting advertisement
  
      mBluetoothLeAdvertiser.startAdvertisingSet(parameters, mData, scanResponse, null, null, callback);
  </code></pre>