Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Created April 2, 2020 07:07
Show Gist options
  • Save MrCrambo/54217a7fae5ed163745f61cb5068f919 to your computer and use it in GitHub Desktop.
Save MrCrambo/54217a7fae5ed163745f61cb5068f919 to your computer and use it in GitHub Desktop.
mRttBroadcastReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent)
{
try
{
for (ScanResult scanResult: mWifiManager.getScanResults())
{
if (scanResult.is80211mcResponder())
{
RangingRequest.Builder rB = new RangingRequest.Builder();
rB.addAccessPoint(scanResult);
WifiRttManager rttManager = (WifiRttManager) mContext.getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
RangingResultCallback callback = mCallback; // your callback is here
rttManager.startRanging(rangingRequestBuilder.build(),
mContext.getMainExecutor(),
callback);
}
}
}
catch (Throwable e) { }
}
};
mContext.registerReceiver(mWifiBroadcastReceiver, newIntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment