Start a new topic

POI Unstable position when reopen project

POI Unstable position when reopen project


Hi,

As I tried to explain - if you're testing with the original wikitude sample app - it's expected behaviour that with every start of the AR view the position of the POIs change. As we're using random positions for displaying the POIs.

So if you didn't change anything in the sample app - the behaviour is expected. Please check the sample code and the documentation to find more details on how the positions are created randomly and how you can load your own POI data.

Greetings

Nicola

i was install example project, let the attach pictures explain

Tell me the truth,

thx

Hi,

Can you pls check the implementation on javascript side. Does the position change or are the POIs 'jumpy' during running the experience. If the position changes with every restart, then maybe you still use the random locations set in the sample app.

Greetings

Nicola

thanks for the answer. POI location is 'jumpy', this is my code :

package com.setiadji.ilaper;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.widget.ListView;
import android.widget.Toast;

import com.wikitude.architect.ArchitectView;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class Fragment_Ar extends Activity implements LocationListener {
    String mylatitude="-6.201501";
    String mylongitude="106.781559";
    String mylocation="(default)";

    private ArchitectView architectView;
    private Intent i;
    private LocationManager lmg;
    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;
    private ActionBarDrawerToggle mDrawerToggle;

    // NavigationDrawer title "Nasdaq" in this example
    private CharSequence mDrawerTitle;

    //  App title "Navigation Drawer" in this example
    private CharSequence mTitle;

    // slider menu items details
    private String navMenuTitles;
    private TypedArray navMenuIcons;

    private ArrayList<NavDrawerItem> navDrawerItems;
    private NavDrawerListAdapter adapter;

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment__ar);

        this.architectView = (ArchitectView) this.findViewById(R.id.architectView);
        final ArchitectView.ArchitectConfig config = new ArchitectView.ArchitectConfig(getResources().getString(R.string.sdk_key) /* license key */);
        this.architectView.onCreate(config);
//         final StartupConfiguration config = new StartupConfiguration("XvEaP3PXm44p+/6wiFZnr6RvL2/nJXrr64Wc4c47mYHPwagtHNLf/sVJG1DKnVVX4R+QMEM4NKMdbjNcio8Vdu4M00ZLZnCpeKTcohCRmTp7NExy3JDR7s0F/9pKmy9ROKyZcEsvXrbXznq2iF5ns8fEoUa5CUwErEsaIJWIMD9TYWx0ZWRfX3XhErXx5V13bNufe+1ICVLu9rBPdYIyVYJwV0JgMbOOSHQ62fF1FivuCnNdwHrzzx7M9MKbOfPDidLQmc8jN7ZCvW9Y+t6hcDDruh5Qrpjqudd5mqHSS+fvO2Yukif06o0JH/pkxCGFITSG0l1QeQhw5J0cInEGnlvQyIGCQ1krGgZSAJT3M1LUAnAN9OGT13nxovfBGkv6oXrzxJl1GTmFinQQywdxiEQh3LbwicDuF1kYN2RWDWvs0bA4Pvp7UASsq4jBcWdGQOqwA6GNP0KD490Tn/qhTOPpWG/ObHswZBmySRU4ZWQYYTiEQ6/57AwLl4ikfkEAs+PN5IZKPd3x6+dz19QWhqQSGgz8N+aOuVoMzs4aWmyEUH+/vmziu4npVPEEg5HJ7bhtIIQPbsefn/+ZTrXGPdJfrJE5iBNArYSq2jZTsMnrFsRPtPmCx0YlUXvpii9Spg6VcVN/TeG8UU7CpzHf0YAik1izjV41TXdFuTZcRAHkn3Wmm8muV8QyUbFdPBfW");
//         this.architectView.onCreate(config);
        //Button b = (Button) findViewById(R.id.addPOI);

//        i = new Intent(this, AddPOI.class);
//        b.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startActivity(i);
//            }
//        });

        LocationManager locationManager;
        String context = Context.LOCATION_SERVICE;
        locationManager = (LocationManager) getSystemService(context);

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        String provider = locationManager.getBestProvider(criteria, true);

        Location location = locationManager.getLastKnownLocation(provider);
        updateWithNewLocation(location);

        locationManager.requestLocationUpdates(provider, 5000, 10, locationListener);


        this.architectView.onPostCreate();
        try {
            this.architectView.load("index.html");
        } catch (IOException ioe) {
            Log.v("HTML loading", "" + ioe.getMessage());
        }

    }

    public void onPause() {
        super.onPause();
        architectView.onPause();
        lmg.removeUpdates(this);
    }

    public void onResume() {
        super.onResume();
        architectView.onResume();
        super.onResume();
        lmg = (LocationManager) this.getSystemService(LOCATION_SERVICE);
        if (lmg.isProviderEnabled(LocationManager.GPS_PROVIDER))
            lmg.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
        lmg.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this);
    }

    public void onDestroy() {
        super.onDestroy();
        architectView.onDestroy();
        lmg.removeUpdates(this);
    }

    @Override
    public void onLocationChanged(Location location) {
        architectView.setLocation(location.getLatitude(), location.getLongitude(), 0.0f);
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        String msg = String.format(getResources().getString(R.string.provider_disabled), provider);
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onProviderEnabled(String provider) {
        String msg = String.format(getResources().getString(R.string.provider_enabled), provider);
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onProviderDisabled(String provider) {
        String msg = String.format(getResources().getString(R.string.provider_disabled), provider);
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    private final LocationListener locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            updateWithNewLocation(location);
        }

        @Override
        public void onProviderDisabled(String provider){
            updateWithNewLocation(null);
        }

        @Override
        public void onProviderEnabled(String provider){ }
        @Override
        public void onStatusChanged(String provider, int status, Bundle extras){ }
    };

    private void updateWithNewLocation(Location location) {
        String latLongString;
        double latitude= Double.parseDouble(mylatitude);
        double longitude= Double.parseDouble(mylongitude);

        String addressString = "default";

        if (location != null) {
            latitude = location.getLatitude();
            longitude = location.getLongitude();
            mylatitude= String.valueOf(latitude);
            mylongitude= String.valueOf(longitude);

            latLongString = "Lat:" + latitude + "nLong:" + longitude;
            Geocoder gc = new Geocoder(this, Locale.getDefault());
            try {
                List<Address> addresses = gc.getFromLocation(latitude, longitude, 1);
                StringBuilder sb = new StringBuilder();
                if (addresses.size() > 0) {
                    Address address = addresses.get(0);

                    for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
                        sb.append(address.getAddressLine(i)).append("\n");

                    sb.append(address.getLocality()).append("\n");
                    sb.append(address.getPostalCode()).append("\n");
                    sb.append(address.getCountryName());
                }
                addressString = sb.toString();
            } catch (IOException e) {}
        } else {
            mylatitude="-6.201501";
            mylongitude="106.781559";
            latLongString="(default)";
        }


        mylocation=latLongString + "\n" + addressString;
        mylatitude= String.valueOf(mylatitude);
        mylongitude= String.valueOf(mylongitude);
    }

}


Have You any idea to solve this problem?
Thanks.

Hi,

If the POI loaction is 'jumpy' - meaning if the when checking the position without leaving and entering the AR view -  the reason might either be that the compass values are not returned accurate or e.g. the GPS positions is not accurate.

If you refer to the different POI locations in the sample app, which change with every start, then this is expected behavior - the locations are chosen randomly.

Greetings

Nicola

please tell me what has happened, if i try to reopen project, position always change to defferent place

using android studio and sdk 5.0

thx
Login or Signup to post a comment