私はMapViewウィジェットを登録するmapActivityを持ち、バックグラウンドで位置データをチェックするサービスを実行しています。このようにBroadcastReceiverを介してmapactivityでサービスを開始しています
public class MainActivity extends MapActivity {
private MapView view;
protected void onCreate(Bundle savedInstanceState) {
view = (MapView) findViewById(R.id.themap);
view.setBuiltInZoomControls(true);
Intent in = new Intent();
MyReceiver locationRecvr = new MyReceiver();
locationRecvr.onReceive(getApplicationContext(), in);
}
......................
}
myReveiver.java
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "MyReceiver Started..",Toast.LENGTH_SHORT).show();
Log.v("Debug", "MyReceiver Started..");
Intent myIntent=new Intent(context, ServiceLocation.class);
context.startService(myIntent);
}
}
および myservice と LocationListener はこのように
public class ServiceLocation extends Service implements LocationListener {
......
.....
....
}
私の質問は、場所が変更されたときに、マップビューでその場所を変更する方法、onLocationchanged() メソッドでマップビュー参照を取得する方法、または緯度と経度を mapActivity に送信する方法です。
前もって感謝します