Note that there are some explanatory texts on larger screens.

plurals
  1. POSimulating GPS Data to Android AVD Not Working
    text
    copied!<p>I’m hoping someone can help me with an issue I’m having with sending emulated GPS data to an Android AVD in Eclipse. If I run the application on a real device everything works fine, but when I attempt to uses the built in emulator in eclipse nothing will happen. I have also tried telneting into the AVD and issuing the geo fix command. Below is the code I am using although I don’t think there is anything wrong with it if it works on the real device</p> <p>The manifest file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.TestGoogleMaps" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:targetSdkVersion="10" android:minSdkVersion="8"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".TestingGoogleMapsActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/LinearLayout&gt; </code></pre> <p>The Main Code</p> <pre><code>package net.TestGoogleMaps; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class TestingGoogleMapsActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); 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, 2000, 10, locationListener); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider){ updateWithNewLocation(null); } public void onProviderEnabled(String provider){ } public void onStatusChanged(String provider, int status, Bundle extras){ } }; public void updateWithNewLocation(Location location) { Context contextApp = getApplicationContext(); String text ; int duration = 2000; if(location == null) { text ="Null Location"; } else { text = "Lat : " + location.getLatitude() + " Lon: " + location.getLongitude(); } Toast toast = Toast.makeText(contextApp, text, duration); toast.show(); } } </code></pre> <p>I will also get the following error sometimes when simulating the GPS data from eclipse to the device in the LogCat tab of eclipse.</p> <pre><code>05-31 02:31:35.158: E/InputQueue-JNI(347): channel '406e6640 net.TestGoogleMaps/net.TestGoogleMaps.TestingGoogleMapsActivity (client)' ~ Publisher closed input channel or an error occurred. events=0x8 </code></pre> <p>Any help would be greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload