2011-12-31 12 views
-3

可能な二重に緯度、経度や住所を取得する方法:
How to retrieve the GPS location via SMSアンドロイド

私はこのように行動しようとしているアンドロイドアプリ作っています: ユーザータイプをアプリケーションを実行している電話機に「findmyphone」などのテキストメッセージ(他の通常のテキストメッセージには応答しません)が含まれていると、アプリケーションはその番号に緯度、経度、およびthのアドレスで自動的に応答しますアプリケーションを実行している電話。

また、テストするためのボタンが必要です。ユーザーが "Test"ボタンを押すと、緯度、経度、住所が2つのテキストボックスに表示され、緯度と経度が1つに表示され、住所がもう1つのテキストボックスに表示されます。ありがとうございます。これは私がこれまで持っているものです。

import java.io.IOException; 
import java.util.List; 
import java.util.Locale; 

import android.app.Activity; 
import android.content.Context; 
import android.location.Address; 
import android.location.Geocoder; 
import android.location.Location; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.TextView; 

public class FindAndroidActivity extends Activity implements OnClickListener { 
/** Called when the activity is first created. */ 
Button Nextbutton1, Nextbutton2, TestLocationService; 
TextView Cordinates, Adress, FindAndroid; 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    Nextbutton1 = (Button)findViewById(R.id.Nextbutton1); 
    Nextbutton1.setOnClickListener(this); 
} 
public void onClick(View src) { 
    switch (src.getId()) { 
    case R.id.Nextbutton1: 
     setContentView(R.layout.setup); 
     Nextbutton2 = (Button)findViewById(R.id.Nextbutton2); 
     Nextbutton2.setOnClickListener(this); 
     TestLocationService = (Button)findViewById(R.id.TestLocationService); 
     TestLocationService.setOnClickListener(this); 
     break; 
    case R.id.Nextbutton2: 
     setContentView(R.layout.main); 
     break; 
    case R.id.TestLocationService: 
     break; 
    } 
} 
    public Address getAddressForLocation(Context context, Location location) throws IOException { 

     if (location == null) { 
      return null; 
     } 
     double latitude = location.getLatitude(); 
     double longitude = location.getLongitude(); 
     int maxResults = 1; 

     Geocoder gc = new Geocoder(context, Locale.getDefault()); 
     List<Address> addresses = gc.getFromLocation(latitude, longitude, maxResults); 

     if (addresses.size() == 1) { 
      return addresses.get(0); 
     } else { 
      return null; 
     } 
} 

}

+4

を見てする必要がある「どのように私は、できるだけ簡単にこれを行うことができますか?」あなたのためにこれを行うには誰かに支払う必要があります...これは最も簡単な解決策です... – Selvin

+1

あなたの持つエラーまたは問題は何ですか?誰でも、スモークスクリーン用のコードをコピーして貼り付けることができます。 – Robert

+0

私が必要とするのは、SMSが届くと、緯度、経度、および住所を取得する方法があります。だから私は私の電話を紛失した場合、私は別の電話を貸して、その電話にSMSを送信する: "PhoneLocate"それはその電話のアドレスと座標で応答します。しかし、その単語がPhoneLocateか、私が指定したものだけです。私はすでにアンドロイド市場のアプリケーションを持っていますが、アプリの発明者で作られています。私はそれを日食で作っていきたいと思いますが、その場所での経験はそれほどありません。アプリケーション名はPhoneLocatorです。 – MySoftware

答えて

0

は、Google検索を行うか、あなたが必要とするほとんどの情報は、StackOverflowのを検索することができますので、私は何の詳細な手順を与えることはありません。

ロケーションを取得するには、LocationManagerを使用し、requestLocationUpdatesを呼び出します。これを行う方法を説明するチュートリアルがたくさんあります。

SMSを受信するには、次のようなあなたのマニフェストで宣言さBroadcastReceiverが必要になります

<receiver android:name=".SmsReceiver"> 
        <intent-filter> 
         <action android:name="android.provider.Telephony.SMS_RECEIVED"/> 
        </intent-filter> 
       </receiver> 

このreceiveryの中で、あなたは、SMSから必要な情報を取得するためにSmsMessageクラスを使用します。

次にSMSを送信するには、SmsManagerを使用し、sendTextMessageを呼び出します。

BUT
本当に自分で作業する必要があります。また、市場に既に電話機ロケータアプリケーションのトーンがあることに注意してください。これは、あなたが作る価値のあるアプリではないかもしれません。

もう一度、stackoverflowまたはGoogleを検索して、必要なものをそれぞれ行う方法を調べることができます。

そして、(あなたはアプリの発明を使用したので)あなたが任意の実際のAndroidのプログラミングを行っていない場合は、Developer's Guide