2012-01-23 14 views
0

私はSurfaceHolderなどを使ってカメラの画像を保持するカメラクラスを持っています。上記のSurfaceView TextViewに入ります。私が質問したいのは、TextViewのテキストをGPSから取得した緯度と経度の値で更新するにはどうすればいいですか? 現在の位置を取得するためにコーディングを行い、位置を更新しますGPSの値を使ってTextViewを編集する

+0

あなたは写真で現在の緯度経度を表示すると言っていますか? – Lucifer

+0

@Luciferのコメントを拡張するには - 何らかの形で[ジオタグ](http://en.wikipedia.org/wiki/Geotagging)を参照していますか? –

答えて

1

コードに以下の変更を加えてみてください。マニフェストファイルで

 textView = (TextView)findViewById(R.id.textViewId); 

     LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
     mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() { 
      @Override 
      public void onLocationChanged(Location loc) { 
       String location = "Last known location\nLatitude = "+loc.getLatitude()+"\nLongitude = "+loc.getLongitude(); 
       textView.setText(location); 
      } 
      @Override 
      public void onProviderDisabled(String provider) { 
       Toast.makeText(getApplicationContext(), "GPS Disabled", Toast.LENGTH_SHORT).show(); 
      } 
      @Override 
      public void onProviderEnabled(String provider) { 
       Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show();     
      } 
      @Override 
      public void onStatusChanged(String provider, int status, Bundle extras) { 
       Toast.makeText(getApplicationContext(), "GPS Status Changed", Toast.LENGTH_SHORT).show();    
      }   
     }); 

あなたは

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"> 

以下のようにアクセス許可を使用する必要があり、私はあなたが理解してほしいと、それはあなたを助けます。

1

LocationManagerからrequireLocationUpdatesを使用します。 一般的にそのプロセスはバックグラウンドに移行します。

0

イムは、私の愚かな質問して申し訳ありません

private void updateWithNewLocation(Location location){ 
     String latLongString; 
     TextView longlati; 
     longlati = (TextView)findViewById(R.id.longlati); 
     if(location != null){ 
      double lat = location.getLatitude(); 
      double lng = location.getLongitude(); 
      latLongString = "Lat: " + lat + "\nLong: " + lng; 
     }else{ 
      latLongString = "No Location found"; 
     } 
     longlati.setText(" " + latLongString); 

    } 

笑..問題解決を発見しました。私はちょっとしたストレス> _ <

関連する問題