Welcome guest, is this your first visit? Click the "Create Account" button now to join.
Results 1 to 10 of 13

Hybrid View

  1. #1
    Master frontzosd's Avatar
    Join Date
    Jun 2012
    Location
    Greece
    Age
    55
    Posts
    616
    Rep Power
    1447

    Default

    Unfortunately, for the electronic compass, first it must be
    supported from the application.
    And after with utilities with lua code.
    Here is an example which
    Enable internal compass
    In java.
    This must be in the primo apk.


    Java example...

    import android.content.Context;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;

    public class InternalCompassOrientationProvider implements SensorEventListener, IOrientationProvider
    {
    private IOrientationConsumer mOrientationConsumer;
    private final SensorManager mSensorManager;
    private float mAzimuth;

    public InternalCompassOrientationProvider(Context context)
    {
    mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    }

    //
    // IOrientationProvider
    //

    /**
    * Enable orientation updates from the internal compass sensor and show the compass.
    */
    @Override
    public boolean startOrientationProvider(IOrientationConsumer orientationConsumer)
    {
    mOrientationConsumer = orientationConsumer;
    boolean result = false;

    final Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    if (sensor != null) {
    result = mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_UI);
    }
    return result;
    }

    @Override
    public void stopOrientationProvider()
    {
    mSensorManager.unregisterListener(this);
    }

    @Override
    public float getLastKnownOrientation()
    {
    return mAzimuth;
    }

    //
    // SensorEventListener
    //

    @Override
    public void onAccuracyChanged(final Sensor sensor, final int accuracy)
    {
    // This is not interesting for us at the moment
    }

    @Override
    public void onSensorChanged(final SensorEvent event)
    {
    if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
    if (event.values != null) {
    mAzimuth = event.values[0];
    if (mOrientationConsumer != null)
    mOrientationConsumer.onOrientationChanged(mAzimuth, this);
    }
    }
    }

  2.    Advertissements


  3. #2
    iGO&Becker Moderator Korabi's Avatar
    Join Date
    Jan 2013
    Location
    Illyria
    Age
    54
    Posts
    422
    Rep Power
    954

    Default

    Quote Originally Posted by frontzosd View Post
    Unfortunately, for the electronic compass, first it must be
    supported from the application.
    And after with utilities with lua code.
    Here is an example which
    Enable internal compass
    In java.
    This must be in the primo apk.


    Java example...

    import android.content.Context;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;

    public class InternalCompassOrientationProvider implements SensorEventListener, IOrientationProvider
    {
    private IOrientationConsumer mOrientationConsumer;
    private final SensorManager mSensorManager;
    private float mAzimuth;

    public InternalCompassOrientationProvider(Context context)
    {
    mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    }

    //
    // IOrientationProvider
    //

    /**
    * Enable orientation updates from the internal compass sensor and show the compass.
    */
    @Override
    public boolean startOrientationProvider(IOrientationConsumer orientationConsumer)
    {
    mOrientationConsumer = orientationConsumer;
    boolean result = false;

    final Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    if (sensor != null) {
    result = mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_UI);
    }
    return result;
    }

    @Override
    public void stopOrientationProvider()
    {
    mSensorManager.unregisterListener(this);
    }

    @Override
    public float getLastKnownOrientation()
    {
    return mAzimuth;
    }

    //
    // SensorEventListener
    //

    @Override
    public void onAccuracyChanged(final Sensor sensor, final int accuracy)
    {
    // This is not interesting for us at the moment
    }

    @Override
    public void onSensorChanged(final SensorEvent event)
    {
    if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
    if (event.values != null) {
    mAzimuth = event.values[0];
    if (mOrientationConsumer != null)
    mOrientationConsumer.onOrientationChanged(mAzimuth, this);
    }
    }
    }
    I do not know where you found this, or you did, but iGO will use the language program. LUA.This language, born in Brazil 20 years ago, lua = moon. is this language that you write tools iGO Win& Android. example. for compass is this :
    Code:
    Please Login or Register to see the links
    Last edited by Korabi; 6th June 2014 at 08:10 PM.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •