Closed agcell closed 6 years ago
This code looks correct. Did you try to scan devices using Administration App? Does it also take so much time to discover beacons?
No, it scans much faster than my code.
So there's something wrong with your code, not SDK. You have to paste more code.
Can you help me out in this what code i need to paste as i have tried many ways.
Everything you need could be found in our documentation. There is nothing difficult here. Here's a link: Documentation
As per the documentation i have followed the same process. When i have added line of code ( .eddystoneFrameTypes(Arrays.asList(EddystoneFrameType.TLM, EddystoneFrameType.UID, EddystoneFrameType.URL))). To solve the instance null value as suggested in the thread (https://github.com/kontaktio/kontakt-android-sdk/issues/164) , i have added this.
What more can I do? Send the full code so I will try to investigate the problem.
Hi , I have uploaded file where i am scanning. Curently i have commented ( .eddystoneFrameTypes(Arrays.asList(EddystoneFrameType.TLM, EddystoneFrameType.UID, EddystoneFrameType.URL))). line of code for fast scanning on start.
But This has issue that it give instance value null. Please help.
Configuration looks okay. The simplest way to find out if ProximityManager
works properly is to remove/comment all functionalities except scanning and see what happens. Below you can find sample code, which is responsible for detecting Eddystones and printing results to logs. I've tested it now and beacons are detected after few seconds. It's all I can do for you.
public class EddystoneScanActivity extends AppCompatActivity {
private static final String TAG = EddystoneScanActivity.class.getSimpleName();
private static final int PERMISSION_REQUEST_CODE_LOCATION = 1;
private static final long UPDATE_INTERVAL = TimeUnit.SECONDS.toMillis(5);
private ProximityManager proximityManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupProximityManager();
if (checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION, getApplicationContext())) {
startScanning();
} else {
requestPermission(Manifest.permission.ACCESS_COARSE_LOCATION, PERMISSION_REQUEST_CODE_LOCATION, this);
}
}
private void setupProximityManager() {
proximityManager = ProximityManagerFactory.create(this);
proximityManager.configuration()
.scanMode(ScanMode.BALANCED)
.scanPeriod(ScanPeriod.RANGING)
.eddystoneFrameTypes(Arrays.asList(EddystoneFrameType.UID, EddystoneFrameType.URL, EddystoneFrameType.TLM))
.deviceUpdateCallbackInterval(UPDATE_INTERVAL);
proximityManager.setEddystoneListener(createEddystoneListener());
}
private void startScanning() {
proximityManager.connect(new OnServiceReadyListener() {
@Override
public void onServiceReady() {
proximityManager.startScanning();
}
});
}
public void requestPermission(String permission, int perCode, Activity activity) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)){
Toast.makeText(getApplicationContext(), "GPS permission needed", Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(activity, new String[] { permission }, perCode);
}
}
public boolean checkPermission(String permission, Context context){
int result = ContextCompat.checkSelfPermission(context, permission);
return result == PackageManager.PERMISSION_GRANTED;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSION_REQUEST_CODE_LOCATION:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startScanning();
} else {
Toast.makeText(getApplicationContext(), "Permission Denied, You cannot access location data.", Toast.LENGTH_LONG).show();
}
break;
}
}
private EddystoneListener createEddystoneListener() {
return new EddystoneListener() {
@Override
public void onEddystoneDiscovered(IEddystoneDevice eddystone, IEddystoneNamespace namespace) {
Log.i(TAG, "Eddystone discovered");
}
@Override
public void onEddystonesUpdated(List<IEddystoneDevice> eddystones, IEddystoneNamespace namespace) {
Log.i(TAG, eddystones.size() + " Eddystones updated");
}
@Override
public void onEddystoneLost(IEddystoneDevice eddystone, IEddystoneNamespace namespace) {
Log.i(TAG, "Eddystone lost");
}
};
}
}
Thanks for the help. I will try to do so .
Hi @sbobowiec ,
I have tried it and found that for some devices it is not working , like yesterday i am testing on samsung device having android version 4.0 device where the class given by you is working fine.
Now today , i am testing on Moto G4 device having android version 7.0 and devices are not getting scanned from around 1 hour. On Moto G4 it works previously. Same time i am working on Intex Aqua device which as android version 6.0 and devices is scanning beacons. On devices same code is running.
This scenario has come to us many times.
Hi @sbobowiec ,
Can you please share us some updates on above issues.
Thanks Nisha
Nisha,
The biggest advantage of Android ecosystem - it's diversity - is at the same time it's biggest problem. There are huge number of various devices, each with their own Bluetooth chipsets, antennas, drivers, Android versions (plus modification made by both manufacturers and sometimes also carriers). All this affects how information about detected beacons are reported to software like our SDK.
You have to keep in mind that Bluetooth signals are not like data that you're getting e.g. from some API when doing network requests. Those are analog signals, that have to be processed by the hardware on your smartphone before are even forwarded to the operating system and later to our SDK. We don't have any way to influence how smartphones handle signals that are broadcasted by beacons. Additionally, the quality of implementation for these subsystems unfortunately can vary significantly even between devices from the same manufacturer. @sbobowiec has already mentioned all tools that are for our disposal.
Hi @adrianz,
Thanks for the feedback.
i will discuss with my team mates.
Regards Nisha
Using KonKakt SDK version : 3.3.1 Configuration of beacon : Using advertising interval value 200 ms and I have a beacon having TLM,UID,URL packet enabled. Issue : I am using below configuration of ProximityManager: ProximityManager proximityManager = ProximityManagerFactory.create(this); //Configure proximity manager basic options proximityManager.configuration() .scanPeriod(ScanPeriod.RANGING) //Using ranging for continuous scanning or MONITORING for scanning with intervals .scanMode(ScanMode.BALANCED) //Using BALANCED for best performance/battery ratio .eddystoneFrameTypes(Arrays.asList(EddystoneFrameType.TLM, EddystoneFrameType.UID, EddystoneFrameType.URL)) .deviceUpdateCallbackInterval(TimeUnit.SECONDS.toMillis(1)); //OnDeviceUpdate callback will be received with 1 seconds interval proximityManager.setEddystoneListener(createEddystoneListener());
But on the start of scanning it takes lot of time (around 1 min) in discovering.
Thanks Nisha