Following the tutorial i’ve built this app but, walking around the location, i see the log that i put in the onLocationUpdate method only one time and the position on my mapdoesn’t change.
In the references it’s said that I have to call startPositionig before start scanning and I do it but…how can I start scanning?
Here is my code, any Idea of what’s wrong?
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
xCookie = -100;
yCookie = -100;
parametriTrilaterazione = new ParametriTrilaterazione();
parametriTrilaterazione.setxCookie(-100);
parametriTrilaterazione.setyCookie(-100);
EstimoteSDK.initialize(getApplicationContext(), "indoor-location-2jh", "01ceed5427c92df4d956c973adb70e1f");
cloudManager = new IndoorCloudManagerFactory().create(getApplicationContext(), new EstimoteCloudCredentials("indoor-location-2jh", "01ceed5427c92df4d956c973adb70e1f"));
b1 = (Button) findViewById(R.id.button);
crediti = (TextView) findViewById(R.id.crediti);
b1.setVisibility(GONE);
crediti.setVisibility(GONE);
(findViewById(R.id.webview3)).setVisibility(View.GONE);
web1 = (WebView) findViewById(R.id.webview1);
web1.setWebViewClient(new WebViewClient());
web1.loadUrl("https://www.ilmeteo.it/");
web1.setVisibility(GONE);
web2 = findViewById(R.id.webview2);
web2.setWebViewClient(new WebViewClient());
web1.loadUrl("https://www.ilmeteo.it/");
web2.setVisibility(GONE);
tele = true;
info = true;
v = (WebView) findViewById(R.id.webview4);
v.setWebViewClient(new WebViewClient());//Per farlo come WebView e non come browser
v.addJavascriptInterface(parametriTrilaterazione, "Android");
CookieSyncManager.createInstance(CONTESTO);
CookieSyncManager.getInstance().startSync();
CookieManager.getInstance().setAcceptCookie(true);
v.getSettings().setJavaScriptEnabled(true);
// setContentView(v);
WebSettings webSettings = v.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
v.getSettings().setDisplayZoomControls(false);
v.loadUrl("file:///android_asset/index.html");
final OnPositionUpdateListener p= new OnPositionUpdateListener()
{
@Override
public void onPositionUpdate(LocationPosition locationPosition)
{
xCookie = (int) locationPosition.getX() * 100;
yCookie = (int) locationPosition.getY() * 100;
Log.d("IndoorLocation", "y "+xCookie);
Log.d("IndoorLocation", "x "+ yCookie);
parametriTrilaterazione.setxCookie(yCookie);
parametriTrilaterazione.setyCookie(xCookie);
Log.d("IndoorLocation", "onPositionUpdate");
if (xCookie > 0 && xCookie < 400 && info)
{
info = false;
tele = false;
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(CONTESTO);
dlgAlert.setMessage("Vuoi visualizzare le informazioni relative al laboratorio di informatica?");
dlgAlert.setTitle("Contenuto disponibile");
dlgAlert.setCancelable(false);
dlgAlert.setPositiveButton("Si",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
informatica();
}
});
dlgAlert.setNegativeButton("No", null);
dlgAlert.create().show();
}
else
{
if (xCookie > 460 && xCookie < 860 && tele)
{
tele = false;
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(CONTESTO);
dlgAlert.setMessage("Vuoi visualizzare le informazioni relative al laboratirio di telecomunicazioni?");
dlgAlert.setTitle("Contenuto disponibile");
dlgAlert.setPositiveButton("Si", null);
dlgAlert.setCancelable(false);
dlgAlert.setPositiveButton("Si", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
informatica();
}
});
dlgAlert.setNegativeButton("No", null);
dlgAlert.create().show();
}
}
Log.d("IndoorLocation", "fine funzione");
}
@Override
public void onPositionOutsideLocation()
{
xCookie = -100;
yCookie = -100;
Log.d("IndoorLocation", "onPositionOutsideLocation");
}
};
CloudCallback<Location> c= new CloudCallback<Location>()
{
@Override
public void success(Location location)
{
locazione=location;
f3=true;
indoorLocationManager = new IndoorLocationManagerBuilder(CONTESTO, locazione, new EstimoteCloudCredentials("indoor-location-2jh", "01ceed5427c92df4d956c973adb70e1f")).withDefaultScanner().build();
indoorLocationManager.setOnPositionUpdateListener(p);
indoorLocationManager.startPositioning();
}
@Override
public void failure(EstimoteCloudException e)
{
}
};
cloudManager.getLocation("amministrazione-s-location-6pi", c);
}
protected void onResume()
{
super.onResume();
SystemRequirementsChecker.checkWithDefaultDialogs(this);
}
@Override
public void onBackPressed()
{
if (obp)
{
v.setVisibility(View.VISIBLE);
web1.setVisibility(GONE);
web2.setVisibility(GONE);
obp = false;
return;
}
v.setVisibility(GONE);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
this.finish();
}
public void setXCookie(int x) {
this.xCookie = x;
}
public void setYCookie(int y) {
this.yCookie = y;
}
public int getXCookie() {
return xCookie;
}
public int getYCookie() {
return yCookie;
}
@Override
protected void onStart() {
super.onStart();
if(f3)
indoorLocationManager.startPositioning();
}
@Override
protected void onStop()
{
super.onStop();
if(indoorLocationManager!=null) {
indoorLocationManager.stopPositioning();
Log.d("IndoorLocation", "stopPositioning");
}
}
}