2012-02-25 95 views
1

我已經做了一個程序,以找到當前位置使用GPS在Android模擬器工作正常,並顯示正確的緯度和經度,我發送從Eclipse模擬器控制,但是有可能在模擬器中的GPS可能單獨顯示我的當前位置,即以一種方式跟蹤我的位置並單獨顯示它,而無需通過模擬器控件發送它。Android模擬器中的GPS可以跟蹤我當前的位置嗎?

下面是代碼:

package location.finder; 

import android.app.Activity; 
import android.content.Context; 
import android.location.Location; 
import android.location.LocationListener; 
import android.location.LocationManager; 
import android.os.Bundle; 
import android.widget.Toast; 

public class LocationFinderActivity extends Activity { 


public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

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

    LocationListener locationListener = new loclistener(); 
     locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener); 

    } 

    public class loclistener implements LocationListener { 

    public void onLocationChanged(Location location){ 
     String loc ="Latitude = " + location.getLatitude() +" Longitude = " + location.getLongitude(); 
     Toast.makeText(getApplicationContext(),loc,Toast.LENGTH_SHORT).show(); 
    } 

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

    public void onProviderEnabled(String provider) 
    { 
     Toast.makeText(getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show(); 

    } 

    public void onProviderDisabled(String provider) 
    { 
     Toast.makeText(getApplicationContext(),"Gps Disabled",Toast.LENGTH_SHORT).show(); 
    } 
} 
} 

回答

1

我orinigal移動猜你不需要做任何事情,因爲它擁有GPS硬件 但仿真器具有GPS「存根」,但它是不嵌入一個真正的硬件在你的電腦,所以它不會自己跟蹤你的位置 這將是更好,如果你提供 你的程序來找到當前位置使用GPS在Android模擬器工作正常,並顯示正確的緯度和經度,我發送從eclipse中的模擬器控制「 ,以便我們可以看到並進一步告訴