2012-05-14 23 views
-3

我想設置一個點作爲模擬器中的當前位置?我在DDMS中使用位置控件,但它不起作用!任何機構都知道如何解決這個問題?提前致謝!!如何將位置推送到模擬器?

+0

你試過這樣啊:http://www.helloandroid.com/tutorials/how-set-location-emulator – Ponmalar

+0

0_0,一些鏈接在中國封鎖,可能鏈接www.helloandroid.com包括在內! –

+0

好吧,請按照下列步驟操作1.進入你的android/tools目錄並啓動DDMS工具 2.選擇模擬器控制選項卡 3.使用經度和緯度值填充位置控制字段 4.按下發送按鈕 – Ponmalar

回答

0

試試這個,

public class NL extends Activity { 

    private LocationManager locmgr = null; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.nl); 

     locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 

    // Define a listener that responds to location updates 
     LocationListener locationListener = new LocationListener() { 
      public void onLocationChanged(Location loc) { 
       // Called when a new location is found by the network location provider. 
       Log.i("NOTIFICATION","onLocationChenged Triggered"); 

       Toast msg = Toast.makeText(NetworkLocator.this, "Lon: " + Double.toString(loc.getLongitude()) + " Lat: " + Double.toString(loc.getLatitude()), Toast.LENGTH_SHORT); 
       msg.show(); 
      } 

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

      public void onProviderEnabled(String provider) {} 

      public void onProviderDisabled(String provider) {} 
      }; 

     // Register the listener with the Location Manager to receive location updates 
     locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); 
    } 
} 

下文稱從Android - Unable to get the gps location on the emulator

相關問題