simon-heinen / droidar

DroidAR Mobile Locationbased Augmented Reality Framework for Android
GNU General Public License v3.0
225 stars 275 forks source link

Current location was unknown, cant do steps #7

Open 90dend opened 11 years ago

90dend commented 11 years ago

package mobi.esys.argeocamere;

import geo.GeoObj; import gl.GL1Renderer; import gl.GLFactory; import system.ArActivity; import system.DefaultARSetup; import util.Vec; import worldData.Entity; import worldData.Obj; import worldData.UpdateTimer; import worldData.Updateable; import worldData.Visitor; import worldData.World; import android.app.Activity; import android.location.Location; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Button button = new Button(this);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ArActivity.startWithSetup(MainActivity.this,
                    new DefaultARSetup() {

                        @Override
                        public void addObjectsTo(GL1Renderer renderer,
                                final World world, GLFactory objectFactory) {
                            Location l = new Location("");
                            l.setLatitude(123);
                            l.setLongitude(123);
                            Obj o = new GeoObj(l);
                            o.setComp(objectFactory.newCube());
                            o.setComp(new Entity() {

                                private Updateable p;
                                private float waitTimeInMilliseconds = 1000;
                                UpdateTimer timer = new UpdateTimer(
                                        waitTimeInMilliseconds, null);

                                @Override
                                public boolean accept(Visitor visitor) {
                                    return false;
                                }

                                @Override
                                public boolean update(float timeDelta,
                                        Updateable parent) {
                                    p = parent;
                                    if (timer.update(timeDelta, parent)) {
                                        // true once a second, do the
                                        // calculation here:
                                        float distanceOfGeoObjToUser = Vec.distance(
                                                ((GeoObj) p)
                                                        .getVirtualPosition(),
                                                world.getMyCamera()
                                                        .getPosition());
                                        Log.d("dist",
                                                String.valueOf(distanceOfGeoObjToUser));
                                    }
                                    return true;
                                }

                                @Override
                                public void setMyParent(Updateable parent) {
                                    this.p = parent;
                                }

                                @Override
                                public Updateable getMyParent() {
                                    return p;
                                }
                            });
                            world.add(o);
                        }
                    });
        }
    });
    setContentView(button);
}

}

simon-heinen commented 11 years ago

can you add your question as well?;)

90dend commented 11 years ago

what do you mean? It my first issue in gitub

simon-heinen commented 11 years ago

just explain why you reported it, what is the scenario? step detection is per default only activated when a valid gps pos is available

On Wed, Jun 19, 2013 at 1:52 PM, 90dend notifications@github.com wrote:

what do you mean? It my first issue in gitub

— Reply to this email directly or view it on GitHubhttps://github.com/bitstars/droidar/issues/7#issuecomment-19678877 .

90dend commented 11 years ago

I try to do app with argumented reality. It's pretty simple, all what I need it show some sign accordingly to defined geo coordinates.I just use code from youtube video http://www.youtube.com/watch?v=MFbEvkWJOV0 and from this project wiki https://github.com/bitstars/droidar/wiki/Example-code-how-to-create-an-object-with-GPS-coordinates-and-display-its-distance but when i run my application it's don't show any signs, and send this messages to logcat

06-19 16:01:24.202: D/SimpleLocationManager(26367): Step detected 06-19 16:01:24.202: D/SimpleLocationManager(26367): > compassAngle=318.09759521484375 06-19 16:01:24.202: D/SimpleLocationManager(26367): > distance=0.9 06-19 16:01:24.202: W/SimpleLocationManager(26367): Current location was unknown, cant do steps

simon-heinen commented 11 years ago

Thats because the device does not yet know its gps position, enable gps and wait until the position bar in the top left of the screen finished loading

On Wed, Jun 19, 2013 at 2:01 PM, 90dend notifications@github.com wrote:

I try to add with argumented reality. It's pretty simple, all what I need it show some sign accordingly to defined geo coordinates.I just use code from youtube video http://www.youtube.com/watch?v=MFbEvkWJOV0 and from this project wiki https://github.com/bitstars/droidar/wiki/Example-code-how-to-create-an-object-with-GPS-coordinates-and-display-its-distancebut when i run my application it's don't show any signs, and in send this messages to logcat

06-19 16:01:24.202: D/SimpleLocationManager(26367): Step detected 06-19 16:01:24.202: D/SimpleLocationManager(26367): > compassAngle=318.09759521484375 06-19 16:01:24.202: D/SimpleLocationManager(26367): > distance=0.9 06-19 16:01:24.202: W/SimpleLocationManager(26367): Current location was unknown, cant do steps

— Reply to this email directly or view it on GitHubhttps://github.com/bitstars/droidar/issues/7#issuecomment-19679283 .

90dend commented 11 years ago

How long it's can take?

simon-heinen commented 11 years ago

depends how often the user uses gps, if gps was activited and used e.g. with google maps before, it wont take long

On Wed, Jun 19, 2013 at 2:04 PM, 90dend notifications@github.com wrote:

How long it's can take?

— Reply to this email directly or view it on GitHubhttps://github.com/bitstars/droidar/issues/7#issuecomment-19679435 .

90dend commented 11 years ago

"wait until the position bar in the top left of the screen finished loading" this freeze on 2%, what is problem?

90dend commented 11 years ago

Can I mistake in manifest file or in including libraries in this case?

90dend commented 11 years ago

I also recive this message in logcat 06-20 13:49:19.277: D/Activity(10459): Camera opened 06-20 13:49:19.287: E/CameraView(10459): Could not set camera parameters: 06-20 13:49:19.287: W/System.err(10459): java.lang.RuntimeException: setParameters failed 06-20 13:49:19.287: W/System.err(10459): at android.hardware.Camera.native_setParameters(Native Method) 06-20 13:49:19.287: W/System.err(10459): at android.hardware.Camera.setParameters(Camera.java:1316) 06-20 13:49:19.287: W/System.err(10459): at system.CameraView.setPreviewAccordingToScreenOrientation(CameraView.java:102) 06-20 13:49:19.287: W/System.err(10459): at system.CameraView.surfaceChanged(CameraView.java:64) 06-20 13:49:19.287: W/System.err(10459): at android.view.SurfaceView.updateWindow(SurfaceView.java:585) 06-20 13:49:19.287: W/System.err(10459): at android.view.SurfaceView.access$000(SurfaceView.java:81) 06-20 13:49:19.287: W/System.err(10459): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173) 06-20 13:49:19.287: W/System.err(10459): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590) 06-20 13:49:19.287: W/System.err(10459): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1820) 06-20 13:49:19.287: W/System.err(10459): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2649) 06-20 13:49:19.287: W/System.err(10459): at android.os.Handler.dispatchMessage(Handler.java:99) 06-20 13:49:19.287: W/System.err(10459): at android.os.Looper.loop(Looper.java:137) 06-20 13:49:19.287: W/System.err(10459): at android.app.ActivityThread.main(ActivityThread.java:4507) 06-20 13:49:19.287: W/System.err(10459): at java.lang.reflect.Method.invokeNative(Native Method) 06-20 13:49:19.287: W/System.err(10459): at java.lang.reflect.Method.invoke(Method.java:511) 06-20 13:49:19.287: W/System.err(10459): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978) 06-20 13:49:19.287: W/System.err(10459): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) 06-20 13:49:19.287: W/System.err(10459): at dalvik.system.NativeStart.main(Native Method)

Can error be here?

dhagz commented 7 years ago

Try modifying SimpleLocationManager#getCurrentLocation() and add this: http://stackoverflow.com/questions/15997079/getlastknownlocation-always-return-null-after-i-re-install-the-apk-file-via-ecli