Start a new topic

Same AR core working/not working depending on phones

Same AR core working/not working depending on phones


Did you find a solution to this issue? I have the exact same issue and even after lots of email exchanges with the support team, it is still not resolved. If you have resolved it, can you given me some pointers on how you resolved it?

Hi there!

Issue seems to be related to the LocationService implementation.
Easiest way to find out is creating a breakpoint in the line where you pass over the user-location using architectView.setLocation().
Also add an alert in JS code's onLocationChanged implementation so you get a better feeling of what's going wrong.

Kind regards,
Andreas

PS.: Please also try to remove ade.js include in your html and let me know if that changed behavior (although I doubt that).

Hi, 

I'm starting with Wikitude creating an Android app. I started which what I believe is a pretty simple code but I have an strange problem with it. It obtains a sample location from the Android java class and shows an image on a sample location stated in the Wikitude core as shown below, it also changes the "Loading..." text for "location changed".

It works perfectly on an Android phone with Android 2.3.4 but the very same app doesn't show the image or "location changed" on an Android 4.2.2 phone. I believe there is nothing in the Android code that makes it not work depending on the version, but here's the code of the html, the Android java class and the manifest.

Thank you very much in advance for your help.

///////////////////////HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta name="viewport" content="target-densitydpi=device-dpi, width = 540, user-scalable = 0" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Your Shop Presentation</title>

 

<!-- Include the ARchitect library -->

<script src="architect://architect.js"></script>

<script src="../ade.js"></script>

 

 

</head>

 

<body>

 

<div class="info" id="messageElement">Loading ...</div>

<div class="info" id="distance"></div>

<div class="info" id="accuracy"></div>

 

<script>

 

var imageResource = new AR.ImageResource("Smiley.png");

stores = ;

markerAnimations = ;

 

//create a new ImageDrawable from an ImageResource and pass some setup parameters

var imageDrawable = new AR.ImageDrawable(imageResource, 5, {

  offsetX : 1,

  //rotation : 190

});

 

//create location

var location1 = new AR.GeoLocation(41.95503613949358, -87.65435457229614);

var location2 = new AR.GeoLocation(41.95547596438594, -87.65453696250916);

 

// a GeoObject which is enabled per default

var geoObject1 = new AR.GeoObject(location2, {

  enabled : true,

  drawables : { cam : imageDrawable}

});

 

AR.context.onLocationChanged = function(latitude, longitude, altitude, accuracy){

  AR.context.onLocationChanged = null;

  var location = new AR.GeoLocation(latitude, longitude, altitude);

  var dist = location2.distanceTo(location);

  document.getElementById("messageElement").innerHTML = "location changed";

  document.getElementById("distance").innerHTML = dist;

  document.getElementById("accuracy").innerHTML = accuracy;

};

 

</script>

 

</body>

</html>

 

?///////////////////////Android:

 


public class AugmentedRealityActivity extends Activity {

 

private ArchitectView architectView;

private String apiKey2="";

 

private final static float  TEST_LATITUDE =  41.95503613949358f;

private final static float  TEST_LONGITUDE = -87.65435457229614f;

private final static float TEST_ALTITUDE = 150;

private final static float  TEST_LATITUDE2 =  41.95503613949359f;

private final static float  TEST_LONGITUDE2 = -87.65435457229615f;

private final static float TEST_ALTITUDE2 = 151;

 

// Acquire a reference to the system Location Manager

LocationManager locationManager;

LocationListener locationListener;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_augmented_reality);

// Show the Up button in the action bar.

setupActionBar();

 

        this.architectView = (ArchitectView) this.findViewById(R.id.architectView);

        

        //create new architect config object with the license key

        ArchitectConfig config = new ArchitectConfig(apiKey2);

        architectView.onCreate(config);

        

        

        locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

     // Define a listener that responds to location updates

    locationListener = new LocationListener() {

       public void onLocationChanged(Location location) {

         // Called when a new location is found by the network location provider.

         //makeUseOfNewLocation(location);

        //architectView.setLocation(location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getAccuracy());

       }

 

       public void onStatusChanged(String provider, int status, Bundle extras) {}

 

       public void onProviderEnabled(String provider) {}

 

       public void onProviderDisabled(String provider) {}

     };

}

 

/**

* Set up the {@link android.app.ActionBar}, if the API is available.

*/

@TargetApi(Build.VERSION_CODES.HONEYCOMB)

private void setupActionBar() {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

getActionBar().setDisplayHomeAsUpEnabled(true);

}

}

 

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.augmented_reality, menu);

return true;

}

 

@Override

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case android.R.id.home:

// This ID represents the Home or Up button. In the case of this

// activity, the Up button is shown. Use NavUtils to allow users

// to navigate up one level in the application structure. For

// more details, see the Navigation pattern on Android Design:

//

// http://developer.android.com/design/patterns/navigation.html#up-vs-back

//

NavUtils.navigateUpFromSameTask(this);

return true;

}

return super.onOptionsItemSelected(item);

}

 

@Override

   protected void onPostCreate(Bundle savedInstanceState) {

    super.onPostCreate(savedInstanceState);

   

    //IMPORTANT: creates ARchitect core modules

    if(this.architectView != null)

    this.architectView.onPostCreate();

   

    try {

    // Register the listener with the Location Manager to receive location updates

    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

   

this.architectView.load("location.html");

this.architectView.setLocation(TEST_LATITUDE, TEST_LONGITUDE, TEST_ALTITUDE, 1f);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

   }

   

@Override

protected void onResume() {

super.onResume();

 

this.architectView.onResume();

}

 

   @Override

   protected void onPause() {

    super.onPause();

    if(this.architectView != null)

    this.architectView.onPause();

   }

   

   @Override

   protected void onDestroy() {

    super.onDestroy();

    if(this.architectView != null)

    this.architectView.onDestroy();

   }

   

   @Override

   public void onLowMemory() {

    super.onLowMemory();

    if(this.architectView != null)

    this.architectView.onLowMemory();

   }   

 

 

}

 


////////////////////////Manifest:

 


<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.myfirstapp"

    android:versionCode="1"

    android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<uses-permission android:name="android.permission.ACCESS_GPS" />

<uses-permission android:name="android.permission.CAMERA" />

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-feature android:name="android.hardware.camera" android:required="true" />

<uses-feature android:name="android.hardware.location" android:required="true" />

<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />

<uses-feature android:name="android.hardware.sensor.compass" android:required="true" />

<uses-feature android:glEsVersion="0x00020000" android:required="true" />

<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="8"/>

 

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:debuggable="true"

        android:theme="@style/AppTheme" >

        <activity

            android:name="com.example.myfirstapp.MainActivity"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

        <activity

            android:name="com.example.myfirstapp.DisplayMessageActivity"

            android:label="@string/title_activity_display_message"

            android:parentActivityName="com.example.myfirstapp.MainActivity" >

            <meta-data

                android:name="android.support.PARENT_ACTIVITY"

                android:value="com.example.myfirstapp.MainActivity" />

        </activity>

        <activity

            android:name="com.example.myfirstapp.AugmentedRealityActivity"

            android:label="@string/title_activity_augmented_reality"

            android:configChanges="screenSize|orientation"

            android:parentActivityName="com.example.myfirstapp.MainActivity" >

            <meta-data

                android:name="android.support.PARENT_ACTIVITY"

                android:value="com.example.myfirstapp.MainActivity" />

        </activity>

    </application>

 

</manifest>

 
Login or Signup to post a comment