AVD GPS 設定 サンプルコード
AVDの設定でHardwareの部分に「GPS support」が「yes」として追加されています?
ちなみに、GPSテストを行ったAndroid2.2-API Level 8で作成したプログラムを載せます。パッケージは適当にaaa.bbbになってますが、適切にかえてください。位置情報が掴めると画面に位置情報などが表示されます。
それと、eclipseのDDMS(ウィンド→パースペクティブを開く→その他→DDMS)のEmulater Controlタブをスクロールバーで下へもってくるとLocation Controlsってのがありますので、位置を変えてsendを押すと情報がかえってきますよ。
----- GpsTest.java ----- package aaa.bbb; import android.app.Activity; import android.location.*; import android.os.Bundle; import android.widget.TextView; public class GpsTest extends Activity implements LocationListener{ LocationManager lm; TextView tv; String bs; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); lm = (LocationManager)getSystemService(LOCATION_SERVICE); bs = lm.getBestProvider( new Criteria(), true); lm.requestLocationUpdates( bs, 10000, 0, this ); Location loc = lm.getLastKnownLocation( bs ); if( loc == null ){ lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); } if( loc == null ){ lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } tv = new TextView(this); setContentView(tv); locDisp( loc ); } void locDisp( Location location ){ String str = "Location is null!\n"; if(location != null){ str = location.toString(); } tv.setText( str + "\n"); } @Override public void onLocationChanged(Location location) { locDisp( location ); } @Override public void onProviderDisabled(String provider) {} @Override public void onProviderEnabled(String provider) {} @Override public void onStatusChanged(String provider, int status, Bundle extras) {} } ----- AndroidManifest.xml ----- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="aaa.bbb" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".GpsTest" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps"/> </application> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> </manifest>