Google api - Vehicle tracking Using Android Map

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I am making my semester project Vehicle tracking Using Android Maps. I am looking for some help. I am receiving locations from vehicle via sms what i want is to display location or update map when i get new sms.

I want to ask how it is possible to update map after some interval or at new sms receive.

for example 12.3245678 , 52.3333333 12.3245689 , 52.3333334 12.3245680 , 52.3333335 12.3245682 , 52.3333336

i know about location.getlangitude() and location listner about i think it only update map using getlanitude() and getlantitude() for GPS trancker and network provider.

but how to set GeoPoint manually and update location listener. or take it as how to update at map we have locations data in database that may also help me

Answers

public class SMSNotificationListener extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
    // Here you can extract the intent extra ( lat , longs )
    // Even you can check some message code to identify valid message
    // Can call some different MapDisplayActivity with lat , longs 
    // in Intent.putExtra(...)
    }

}

Add the receiver in AndroidManifest -

 <receiver android:name=".SMSNotificationListener">
   <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
 </receiver>

Now in MapDisplayActivity ---

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_map);
  mapView = (MapView) findViewById(R.id.mapview);
  setMaptoProvidedLocation();
}

/**
 * Setting Google Map to provided location 
 */
 private void setMaptoProvidedLocation() {
  Intent intent = getIntent();
  LAT = intent.getIntExtra(DisplayActivity.LAT, DisplayActivity.DEF_LAT);
  LNG = intent.getIntExtra(DisplayActivity.LNG, DisplayActivity.DEF_LNG);

  mapView.setBuiltInZoomControls(true);
  mapView.setSatellite(true);
  mapController = mapView.getController();


  mapController.setZoom(ZOOM_LEVEL - ZOOM_LEVEL / 2);
  GeoPoint vehicleLocation = new GeoPoint(LAT, LNG);
  mapController.animateTo(vehicleLocation);
  // You can also add map overlays ...

}

 //If MapDisplayActivity is in forground and we want to update the new location

  @Override
  public void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  setIntent(intent);
  Log.d("MapActivity","Got new Data again");
  setMaptoProvidedLocation(false);
  } 

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/14377487/vehicle-tracking-using-android-map

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils