2012-01-05 11 views
1

私はlatituideと経度の詳細を取得する必要があり、詳細を取得しているアプリを開発していますが、私はその詳細を入れてhttp://itouchmap.com/latlong.html私は間違ったlocation.Myコードは次のとおりです:次のようにアンドロイド:緯度経度を実装

Log.v("----------","mlocManager"); 
    mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
    mlocListener = new MyLocationListener(); 
    mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 300000, 40, mlocListener); 

と場所クラスがある:代わりにネットワークプロバイダ

public class MyLocationListener implements LocationListener 
{ 
    public void onLocationChanged(final Location loc) 
    { 


     try 
     { 

     System.out.println("............ ..............................Location changedin 11"); 
     latitude = loc.getLatitude();// here the app is getting lat 
     longitude = loc.getLongitude(); // and here long 
     altitude=loc.getAltitude(); 

     String s= Double.toString(latitude); 
     String lat=s.substring(0, 2); 
     String lat1=s.substring(3, 5); 
     String lat2=s.substring(5, 7); 
     String lat3=s.substring(7, 9); 

      finallat=lat+(char) 0x00B0 +lat1+"'"+lat2+"."+lat3+"''"; 
     System.out.println("finallat"+finallat); 


     String s1= Double.toString(longitude); 
     String longt=s1.substring(0, 2); 
     String longt1=s.substring(3, 5); 
     String longt2=s.substring(5, 7); 
     String longt3=s.substring(7, 9); 

     finalllong=longt+(char) 0x00B0 +longt1+"'"+longt2+"."+longt3+"''"; 
     System.out.println("finallong:"+finalllong); 

     System.out.println("newwwwww"+(char) 0X00B1); 

     loc.getAccuracy(); 
     System.out.println("altitude : "+loc.hasAltitude()); 



     latitudee=(TextView)findViewById(R.id.latitudee); 
     latitudee.setText(finallat); 

     longitudee=(TextView)findViewById(R.id.longitudee); 
     longitudee.setText(""+finalllong); 

     accuracyy=(TextView)findViewById(R.id.accuracyy); 
     accuracyy.setText(""+(char) 0X00B1+loc.getAccuracy()+"m"); 
     System.out.println("acc : "+""+(char) 0X00B1+loc.getAccuracy()+"m"); 

     System.out.println("alti:"+altitude); 



      } 

    @Override 
    public void onProviderDisabled(String provider) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void onProviderEnabled(String provider) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void onStatusChanged(String provider, int status, Bundle extras) { 
     // TODO Auto-generated method stub 

    } 
+0

地図上にどのような場所が表示されていますか? – Android

+0

Arjun正確な位置が30.73であるとしますが、それでも30.7276となっていますので、 –

+0

でOKです。この時点でどのような結果が期待されていますか? – Android

答えて

1

使用GPSプロバイダ、それは作品と私のコードを実行しますFOLようです最低:

mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
mlocListener = new MyLocationListener(); 
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 300000, 40, mlocListener);