Example usage for android.location Location setSpeed

List of usage examples for android.location Location setSpeed

Introduction

In this page you can find the example usage for android.location Location setSpeed.

Prototype

public void setSpeed(float speed) 

Source Link

Document

Set the speed, in meters/second over ground.

Usage

From source file:Main.java

public static Location readLocation(Parcel in) {
    Location loc = new Location(in.readString());
    loc.setTime(in.readLong());/*from   w  ww  . j ava  2 s.c  o m*/
    loc.setLatitude(in.readDouble());
    loc.setLongitude(in.readDouble());
    loc.setAltitude(in.readDouble());
    loc.setAccuracy(in.readFloat());
    loc.setBearing(in.readFloat());
    loc.setSpeed(in.readFloat());
    return loc;
}

From source file:export.format.FacebookCourse.java

private JSONArray trail(long activityId) throws JSONException {
    final String cols[] = { DB.LOCATION.TYPE, DB.LOCATION.LATITUDE, DB.LOCATION.LONGITUDE, DB.LOCATION.TIME,
            DB.LOCATION.SPEED };//from   w  ww  .ja v a 2 s  . c o  m
    Cursor c = mDB.query(DB.LOCATION.TABLE, cols, DB.LOCATION.ACTIVITY + " = " + activityId, null, null, null,
            null);
    if (c.moveToFirst()) {
        Location prev = null, last = null;
        double sumDist = 0;
        long sumTime = 0;
        double accTime = 0;
        final double period = 30;
        JSONArray arr = new JSONArray();
        do {
            switch (c.getInt(0)) {
            case DB.LOCATION.TYPE_START:
            case DB.LOCATION.TYPE_RESUME:
                last = new Location("Dill");
                last.setLatitude(c.getDouble(1));
                last.setLongitude(c.getDouble(2));
                last.setTime(c.getLong(3));
                accTime = period * 1000; // always emit first point
                                         // start/resume
                break;
            case DB.LOCATION.TYPE_END:
                accTime = period * 1000; // always emit last point
            case DB.LOCATION.TYPE_GPS:
            case DB.LOCATION.TYPE_PAUSE:
                Location l = new Location("Sill");
                l.setLatitude(c.getDouble(1));
                l.setLongitude(c.getDouble(2));
                l.setTime(c.getLong(3));
                if (!c.isNull(4))
                    l.setSpeed(c.getFloat(4));
                if (last != null) {
                    sumDist += l.distanceTo(last);
                    sumTime += l.getTime() - last.getTime();
                    accTime += l.getTime() - last.getTime();
                }
                prev = last;
                last = l;
            }
            if (Math.round(accTime / 1000) >= period) {
                arr.put(point(prev, last, sumTime, sumDist));
                accTime -= period * 1000;
            }
        } while (c.moveToNext());
        c.close();
        return arr;
    }
    c.close();
    return null;
}

From source file:to.sven.androidrccar.common.communication.model.LocationMessage.java

/**
 * Converts the Location Message to {@link Location}.
 * @return An {@link Location} with the information of this Message.
 *///from   ww w. j a  v  a  2s .  c o m
public Location toAndroidLocation() {
    Location location = new Location((String) null);
    location.setLatitude(latitude);
    location.setLongitude(longitude);
    if (hasAltitude) {
        location.setAltitude(altitude);
    }
    if (hasAccuracy) {
        location.setAccuracy(accuracy);
    }
    if (hasBearing) {
        location.setBearing(bearing);
    }
    if (hasSpeed) {
        location.setSpeed(speed);
    }

    return location;
}

From source file:com.kevinquan.android.location.SimpleRecordedLocation.java

public Location asLocation() {
    Location location = new Location(TAG);
    location.setLatitude(mLatitude);/*from  w w w.jav  a2s .  c om*/
    location.setLongitude(mLongitude);
    location.setAccuracy(mAccuracy);
    location.setAltitude(mAltitude);
    location.setBearing(mBearing);
    location.setSpeed(mSpeed);
    location.setTime(mRecordedAt);
    return location;
}

From source file:mx.itesm.logistics.vehicle_tracking.service.LocationManagerService.java

protected void initLocation(edu.mit.lastmite.insight_library.model.Location location) {
    if (mLastLocation != null) {
        long seconds = (location.getTime() - mLastLocation.getTime()) / 1000;
        android.location.Location lastLocation = new android.location.Location("");
        lastLocation.setLatitude(mLastLocation.getLatitude());
        lastLocation.setLongitude(mLastLocation.getLongitude());

        android.location.Location newLocation = new android.location.Location("");
        newLocation.setLatitude(location.getLatitude());
        newLocation.setLongitude(location.getLongitude());

        float distanceInMeters = lastLocation.distanceTo(newLocation);
        float speed = 0.0f;
        if (seconds != 0) {
            speed = distanceInMeters / seconds * 3.6f;
        }/*from  w w  w. j  a  v  a  2  s .  c  om*/
        location.setSpeed(speed);
    }
    mLastLocation = location;
}

From source file:org.cowboycoders.cyclisimo.turbo.TurboService.java

private synchronized void updateLocation(LatLongAlt pos) {
    LocationManager locationManager = (LocationManager) getApplicationContext()
            .getSystemService(Context.LOCATION_SERVICE);
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        try {/*from  w w  w .  j  a v  a  2s .c o  m*/
            float locSpeed = (float) (lastRecordedSpeed / UnitConversions.MS_TO_KMH);
            final long timestamp = System.currentTimeMillis();
            Log.v(TAG, "location timestamp: " + timestamp);
            Location loc = new Location(MOCK_LOCATION_PROVIDER);
            Log.d(TAG, "alt: " + pos.getAltitude());
            Log.d(TAG, "lat: " + pos.getLatitude());
            Log.d(TAG, "long: " + pos.getLongitude());
            loc.setLatitude(pos.getLatitude());
            loc.setLongitude(pos.getLongitude());
            loc.setAltitude(pos.getAltitude());
            loc.setTime(timestamp);
            loc.setSpeed(locSpeed);
            loc.setAccuracy(GPS_ACCURACY);
            locationManager.setTestProviderLocation(MOCK_LOCATION_PROVIDER, loc);
            Log.e(TAG, "updated location");
        } catch (SecurityException e) {
            handleException(e, "Error updating location", true, NOTIFCATION_ID_STARTUP);
        }

        return;
    }
    Log.e(TAG, "no gps provider");

}

From source file:org.cowboycoders.cyclismo.turbo.TurboService.java

private synchronized void updateLocation(LatLongAlt pos) {
    try {/*from  w w  w.  j  a va  2 s.c o m*/
        float locSpeed = (float) (lastRecordedSpeed / UnitConversions.MS_TO_KMH);
        final long timestamp = System.currentTimeMillis();
        Log.v(TAG, "location timestamp: " + timestamp);
        Location loc = new Location(MOCK_LOCATION_PROVIDER);
        Log.d(TAG, "alt: " + pos.getAltitude());
        Log.d(TAG, "lat: " + pos.getLatitude());
        Log.d(TAG, "long: " + pos.getLongitude());
        loc.setLatitude(pos.getLatitude());
        loc.setLongitude(pos.getLongitude());
        loc.setAltitude(pos.getAltitude());
        // TODO(dszumski) one possible way to correct
        // long timeCorrection = (long) (1000.0 * (delta / lastRecordedSpeed));
        // loc.setTime(timestamp - timeCorrection);
        loc.setTime(timestamp);
        loc.setSpeed(locSpeed);
        loc.setAccuracy(gpsAccuracy);
        Method locationJellyBeanFixMethod = null;
        try {
            locationJellyBeanFixMethod = Location.class.getMethod("makeComplete");
        } catch (NoSuchMethodException e) {
            // ignore
        }
        if (locationJellyBeanFixMethod != null) {
            locationJellyBeanFixMethod.invoke(loc);
        }
        unpauseRecording(); // automatically resume on location updates
        broadcastLocation(loc);
        Log.d(TAG, "updated location");
    } catch (SecurityException e) {
        // is this possible now we aren't using mock locations?
        handleException(e, "Error updating location", true, NOTIFCATION_ID_STARTUP);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:org.ohmage.reminders.types.location.LocTrigService.java

private void handleGPSTimeoutAlarm() {
    Log.v(TAG, "LocTrigService: Handling GPS timeout");

    //If insufficient samples are obtained, timeout the GPS
    if (mNSamples < SAMPLES_LIMIT) {
        Log.v(TAG, "LocTrigService: Unable to obtain samples. " + "Timing out");

        /* If a pass-through checking is scheduled, notify the user
         * anyway. This is because when the GPS times out when a pass
         * through check is scheduled, most likely the user has entered
         * a building. Thus, it would a best to assume that the user is
         * staying at the location of interest where the pass through
         * checking has been scheduled./* www .j a v a  2 s  .  co m*/
         */
        if (mPassThroughChecking) {
            mPassThroughChecking = false;

            Log.v(TAG,
                    "LocTrigService: Unable to verify location" + " after passthrough timer, still notifying");

            triggerIfRequired(mPassThroughCheckCateg);
        }

        //Assume speed = 0 here. This will help the sleep time
        //to slowly buildup to maximum value if the user continues
        //to remain in a place where it is difficult to get GPS
        //samples
        Location loc = new Location(LocationManager.GPS_PROVIDER);
        loc.setSpeed(0);
        recordSpeed(loc);

        reScheduleGPS();
    }
}

From source file:org.ohmage.triggers.types.location.LocTrigService.java

private void handleGPSTimeoutAlarm() {
    Log.i(DEBUG_TAG, "LocTrigService: Handling GPS timeout");

    //If insufficient samples are obtained, timeout the GPS
    if (mNSamples < SAMPLES_LIMIT) {
        Log.i(DEBUG_TAG, "LocTrigService: Unable to obtain samples. " + "Timing out");

        /* If a pass-through checking is scheduled, notify the user
         * anyway. This is because when the GPS times out when a pass
         * through check is scheduled, most likely the user has entered
         * a building. Thus, it would a best to assume that the user is
         * staying at the location of interest where the pass through 
         * checking has been scheduled./*from  w  w  w  .j ava2 s. co  m*/
         */
        if (mPassThroughChecking) {
            mPassThroughChecking = false;

            Log.i(DEBUG_TAG,
                    "LocTrigService: Unable to verify location" + " after passthrough timer, still notifying");

            triggerIfRequired(mPassThroughCheckCateg);
        }

        //Assume speed = 0 here. This will help the sleep time
        //to slowly buildup to maximum value if the user continues
        //to remain in a place where it is difficult to get GPS 
        //samples
        Location loc = new Location(LocationManager.GPS_PROVIDER);
        loc.setSpeed(0);
        recordSpeed(loc);

        reScheduleGPS();
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@SuppressLint("NewApi")
public boolean onOptionsItemSelected_wrapper(int id) {
    // Handle item selection
    switch (id) {
    case 1://w  w w.j a  va2  s  .c om
        // zoom in
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 1);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        // if we zoom, hide the bubble
        if (N_NavitGraphics.NavitAOverlay != null) {
            N_NavitGraphics.NavitAOverlay.hide_bubble();
        }
        Log.e("Navit", "onOptionsItemSelected -> zoom in");
        break;
    case 2:
        // zoom out
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 2);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        // if we zoom, hide the bubble
        if (N_NavitGraphics.NavitAOverlay != null) {
            N_NavitGraphics.NavitAOverlay.hide_bubble();
        }
        Log.e("Navit", "onOptionsItemSelected -> zoom out");
        break;
    case 3:
        // map download menu
        Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
        this.startActivityForResult(map_download_list_activity, Navit.NavitDownloaderPriSelectMap_id);
        break;
    case 5:
        toggle_poi_pref();
        set_poi_layers();
        draw_map();
        break;
    case 6:
        // ok startup address search activity (online google maps search)
        Navit.use_index_search = false;
        Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
        search_intent.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent.putExtra("address_string", Navit_last_address_search_string);
        //search_intent.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent.putExtra("type", "online");
        String pm_temp = "0";
        if (Navit_last_address_partial_match) {
            pm_temp = "1";
        }
        search_intent.putExtra("partial_match", pm_temp);
        this.startActivityForResult(search_intent, NavitAddressSearch_id_online);
        break;
    case 7:
        // ok startup address search activity (offline binfile search)
        Navit.use_index_search = Navit.allow_use_index_search();
        Intent search_intent2 = new Intent(this, NavitAddressSearchActivity.class);
        search_intent2.putExtra("title", Navit.get_text("Enter: City and Street")); //TRANS
        search_intent2.putExtra("address_string", Navit_last_address_search_string);
        search_intent2.putExtra("hn_string", Navit_last_address_hn_string);
        search_intent2.putExtra("type", "offline");
        search_intent2.putExtra("search_country_id", Navit_last_address_search_country_id);

        String pm_temp2 = "0";
        if (Navit_last_address_partial_match) {
            pm_temp2 = "1";
        }

        search_intent2.putExtra("partial_match", pm_temp2);
        this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
        break;
    case 8:
        // map delete menu
        Intent map_delete_list_activity2 = new Intent(this, NavitDeleteSelectMapActivity.class);
        this.startActivityForResult(map_delete_list_activity2, Navit.NavitDeleteSecSelectMap_id);
        break;
    case 9:
        // stop navigation (this menu should only appear when navigation is actually on!)
        Message msg2 = new Message();
        Bundle b2 = new Bundle();
        b2.putInt("Callback", 7);
        msg2.setData(b2);
        NavitGraphics.callback_handler.sendMessage(msg2);
        Log.e("Navit", "stop navigation");
        break;
    case 10:
        // open settings menu
        Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
        startActivity(settingsActivity);
        break;
    case 11:
        //zoom_to_route
        zoom_to_route();
        break;
    case 12:

        // --------- make app crash ---------
        // --------- make app crash ---------
        // --------- make app crash ---------
        // ** // DEBUG // ** // crash_app_java(1);
        // ** // DEBUG // ** // crash_app_C();
        // --------- make app crash ---------
        // --------- make app crash ---------
        // --------- make app crash ---------

        // announcer off
        Navit_Announcer = false;
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 34);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        try {
            invalidateOptionsMenu();
        } catch (Exception e) {
        }
        break;
    case 13:
        // announcer on
        Navit_Announcer = true;
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 35);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        try {
            invalidateOptionsMenu();
        } catch (Exception e) {
        }
        break;
    case 14:
        // show recent destination list
        Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
        this.startActivityForResult(i2, Navit.NavitRecentDest_id);
        break;
    case 15:
        // show current target on googlemaps
        String current_target_string = NavitGraphics.CallbackGeoCalc(4, 1, 1);
        // Log.e("Navit", "got target  1: "+current_target_string);
        if (current_target_string.equals("x:x")) {
            Log.e("Navit", "no target set!");
        } else {
            try {
                String tmp[] = current_target_string.split(":", 2);
                googlemaps_show(tmp[0], tmp[1], "ZANavi Target");
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with target!");
            }
        }
        break;
    case 16:
        // show online manual
        Log.e("Navit", "user wants online help, show the website lang="
                + NavitTextTranslations.main_language.toLowerCase());
        // URL to ZANavi Manual (in english language)
        String url = "http://zanavi.cc/index.php/Manual";
        if (FDBL) {
            url = "http://fd.zanavi.cc/manual";
        }
        if (NavitTextTranslations.main_language.toLowerCase().equals("de")) {
            // show german manual
            url = "http://zanavi.cc/index.php/Manual/de";
            if (FDBL) {
                url = "http://fd.zanavi.cc/manualde";
            }
        }

        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
        break;
    case 17:
        // show age of maps (online)
        Intent i3 = new Intent(Intent.ACTION_VIEW);
        i3.setData(Uri.parse(NavitMapDownloader.ZANAVI_MAPS_AGE_URL));
        startActivity(i3);
        break;
    case 18:
        Intent intent_latlon = new Intent(Intent.ACTION_MAIN);
        //intent_latlon.setAction("android.intent.action.POINTPICK");
        intent_latlon.setPackage("com.cruthu.latlongcalc1");
        intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongMain");
        //intent_latlon.setClassName("com.cruthu.latlongcalc1", "com.cruthu.latlongcalc1.LatLongPointPick");
        try {
            startActivity(intent_latlon);
        } catch (Exception e88) {
            e88.printStackTrace();
            // show install page
            try {
                // String urlx = "http://market.android.com/details?id=com.cruthu.latlongcalc1";
                String urlx = "market://details?id=com.cruthu.latlongcalc1";
                Intent ix = new Intent(Intent.ACTION_VIEW);
                ix.setData(Uri.parse(urlx));
                startActivity(ix);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        break;
    case 19:
        // GeoCoordEnterDialog
        Intent it001 = new Intent(this, GeoCoordEnterDialog.class);
        this.startActivityForResult(it001, Navit.NavitGeoCoordEnter_id);
        break;
    case 20:
        // convert GPX file
        Intent intent77 = new Intent(getBaseContext(), FileDialog.class);
        File a = new File(p.PREF_last_selected_dir_gpxfiles);
        try {
            // convert the "/../" in the path to normal absolut dir
            intent77.putExtra(FileDialog.START_PATH, a.getCanonicalPath());
            //can user select directories or not
            intent77.putExtra(FileDialog.CAN_SELECT_DIR, false);
            // disable the "new" button
            intent77.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
            //alternatively you can set file filter
            //intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "gpx" });
            startActivityForResult(intent77, Navit.NavitGPXConvChooser_id);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        break;
    case 21:
        // add traffic block (like blocked road, or construction site) at current location of crosshair
        try {
            String traffic = "";
            if (Navit.GFX_OVERSPILL) {
                traffic = NavitGraphics.CallbackGeoCalc(7,
                        (int) (NavitGraphics.Global_dpi_factor
                                * (NavitGraphics.mCanvasWidth / 2 + NavitGraphics.mCanvasWidth_overspill)),
                        (int) (NavitGraphics.Global_dpi_factor
                                * (NavitGraphics.mCanvasHeight / 2 + NavitGraphics.mCanvasHeight_overspill)));
            } else {
                traffic = NavitGraphics.CallbackGeoCalc(7,
                        (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasWidth / 2),
                        (int) (NavitGraphics.Global_dpi_factor * NavitGraphics.mCanvasHeight / 2));
            }

            // System.out.println("traffic=" + traffic);
            File traffic_file_dir = new File(MAP_FILENAME_PATH);
            traffic_file_dir.mkdirs();
            File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
            FileOutputStream fOut = null;
            OutputStreamWriter osw = null;
            try {
                fOut = new FileOutputStream(traffic_file, true);
                osw = new OutputStreamWriter(fOut);
                osw.write("type=traffic_distortion maxspeed=0" + "\n"); // item header
                osw.write(traffic); // item coordinates
                osw.close();
                fOut.close();
            } catch (Exception ef) {
                ef.printStackTrace();
            }

            // update route, if a route is set
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 73);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case 22:
        // clear all traffic blocks
        try {
            File traffic_file = new File(MAP_FILENAME_PATH + "/traffic.txt");
            traffic_file.delete();

            // update route, if a route is set
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 73);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
        break;
    case 23:
        // clear all GPX maps
        try {
            File gpx_file = new File(MAP_FILENAME_PATH + "/gpxtracks.txt");
            gpx_file.delete();

            // draw map no-async
            msg = new Message();
            b = new Bundle();
            b.putInt("Callback", 64);
            msg.setData(b);
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
        break;
    case 24:
        // show feedback form
        Intent i4 = new Intent(this, NavitFeedbackFormActivity.class);
        this.startActivityForResult(i4, Navit.NavitSendFeedback_id);
        break;
    case 25:
        // share the current destination with your friends         
        String current_target_string2 = NavitGraphics.CallbackGeoCalc(4, 1, 1);
        if (current_target_string2.equals("x:x")) {
            Log.e("Navit", "no target set!");
        } else {
            try {
                String tmp[] = current_target_string2.split(":", 2);

                if (Navit.OSD_route_001.arriving_time_valid) {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), Navit.OSD_route_001.arriving_time, true);
                } else {
                    share_location(tmp[0], tmp[1], Navit.get_text("Meeting Point"),
                            Navit.get_text("Meeting Point"), "", true);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with target!");
            }
        }
        break;
    case 26:
        // donate
        Log.e("Navit", "start donate app");
        donate();
        break;
    case 27:
        // donate
        Log.e("Navit", "donate bitcoins");
        donate_bitcoins();
        break;
    case 28:
        // replay GPS file
        Intent intent771 = new Intent(getBaseContext(), FileDialog.class);
        File a1 = new File(Navit.NAVIT_DATA_DEBUG_DIR);
        try {
            // convert the "/../" in the path to normal absolut dir
            intent771.putExtra(FileDialog.START_PATH, a1.getCanonicalPath());
            //can user select directories or not
            intent771.putExtra(FileDialog.CAN_SELECT_DIR, false);
            // disable the "new" button
            intent771.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
            //alternatively you can set file filter
            intent771.putExtra(FileDialog.FORMAT_FILTER, new String[] { "txt", "yaml" });
            startActivityForResult(intent771, Navit.NavitReplayFileConvChooser_id);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        break;
    case 29:
        // About Screen
        Intent it002 = new Intent(this, ZANaviAboutPage.class);
        this.startActivityForResult(it002, Navit.ZANaviAbout_id);
        break;
    case 88:
        // dummy entry, just to make "breaks" in the menu
        break;
    case 601:
        // DEBUG: activate demo vehicle and set position to position to screen center

        Navit.DemoVehicle = true;

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 101);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        final Thread demo_v_001 = new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000); // wait 1 seconds before we start

                    try {
                        float lat = 0;
                        float lon = 0;

                        String lat_lon = "";
                        if (Navit.GFX_OVERSPILL) {
                            lat_lon = NavitGraphics.CallbackGeoCalc(1, NavitGraphics.Global_dpi_factor
                                    * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill),
                                    NavitGraphics.Global_dpi_factor * (NG__map_main.view.getHeight() / 2
                                            + NavitGraphics.mCanvasHeight_overspill));
                        } else {
                            lat_lon = NavitGraphics.CallbackGeoCalc(1,
                                    NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2,
                                    NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
                        }
                        String tmp[] = lat_lon.split(":", 2);
                        //System.out.println("tmp=" + lat_lon);
                        lat = Float.parseFloat(tmp[0]);
                        lon = Float.parseFloat(tmp[1]);
                        //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
                        Location l = null;
                        l = new Location("ZANavi Demo 001");
                        l.setLatitude(lat);
                        l.setLongitude(lon);
                        l.setBearing(0.0f);
                        l.setSpeed(0);
                        l.setAccuracy(4.0f); // accuracy 4 meters
                        // NavitVehicle.update_compass_heading(0.0f);
                        NavitVehicle.set_mock_location__fast(l);
                    } catch (Exception e) {
                    }

                    Message msg = new Message();
                    Bundle b = new Bundle();
                    b.putInt("Callback", 52);
                    b.putString("s", "45"); // speed in km/h of Demo-Vehicle
                    // b.putString("s", "20");

                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);
                } catch (Exception e) {
                }
            }
        };
        demo_v_001.start();

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 51);

        if (Navit.GFX_OVERSPILL) {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
        } else {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
        }
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        break;
    case 602:
        // DEBUG: toggle textview with spoken and translated string (to help with translation)
        try {
            if (NavitGraphics.NavitMsgTv2_.getVisibility() == View.VISIBLE) {
                NavitGraphics.NavitMsgTv2_.setVisibility(View.GONE);
                NavitGraphics.NavitMsgTv2_.setEnabled(false);
                NavitGraphics.NavitMsgTv2sc_.setVisibility(View.GONE);
                NavitGraphics.NavitMsgTv2sc_.setEnabled(false);
            } else {
                NavitGraphics.NavitMsgTv2sc_.setVisibility(View.VISIBLE);
                NavitGraphics.NavitMsgTv2sc_.setEnabled(true);
                NavitGraphics.NavitMsgTv2_.setVisibility(View.VISIBLE);
                NavitGraphics.NavitMsgTv2_.setEnabled(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;
    case 603:
        // DEBUG: show all possible navigation commands (also translated)
        NavitGraphics.generate_all_speech_commands();
        break;
    case 604:
        // DEBUG: activate FAST driving demo vehicle and set position to screen center

        Navit.DemoVehicle = true;

        msg = new Message();

        b = new Bundle();
        b.putInt("Callback", 52);
        b.putString("s", "800"); // speed in ~km/h of Demo-Vehicle
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 51);
        if (Navit.GFX_OVERSPILL) {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getWidth() / 2) + NavitGraphics.mCanvasWidth_overspill)));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor
                    * ((Navit.NG__map_main.view.getHeight() / 2) + NavitGraphics.mCanvasHeight_overspill)));
        } else {
            b.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
            b.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
        }
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);

        try {
            float lat = 0;
            float lon = 0;

            lat = 0;
            lon = 0;
            String lat_lon = "";
            if (Navit.GFX_OVERSPILL) {
                lat_lon = NavitGraphics.CallbackGeoCalc(1,
                        NavitGraphics.Global_dpi_factor
                                * (NG__map_main.view.getWidth() / 2 + NavitGraphics.mCanvasWidth_overspill),
                        NavitGraphics.Global_dpi_factor
                                * (NG__map_main.view.getHeight() / 2 + NavitGraphics.mCanvasHeight_overspill));
            } else {
                lat_lon = NavitGraphics.CallbackGeoCalc(1,
                        NavitGraphics.Global_dpi_factor * NG__map_main.view.getWidth() / 2,
                        NavitGraphics.Global_dpi_factor * NG__map_main.view.getHeight() / 2);
            }

            String tmp[] = lat_lon.split(":", 2);
            //System.out.println("tmp=" + lat_lon);
            lat = Float.parseFloat(tmp[0]);
            lon = Float.parseFloat(tmp[1]);
            //System.out.println("ret=" + lat_lon + " lat=" + lat + " lon=" + lon);
            Location l = null;
            l = new Location("ZANavi Demo 001");
            l.setLatitude(lat);
            l.setLongitude(lon);
            l.setBearing(0.0f);
            l.setSpeed(0);
            l.setAccuracy(4.0f); // accuracy 4 meters
            // NavitVehicle.update_compass_heading(0.0f);
            NavitVehicle.set_mock_location__fast(l);
        } catch (Exception e) {
        }

        break;
    case 605:
        // DEBUG: toggle Routgraph on/off
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 71);
        Navit.Routgraph_enabled = 1 - Navit.Routgraph_enabled;
        b.putString("s", "" + Navit.Routgraph_enabled);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        break;
    case 606:
        // DEBUG: spill contents of index file(s)
        msg = new Message();
        b = new Bundle();
        b.putInt("Callback", 83);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
        break;
    case 607:
        export_map_points_to_sdcard();
        break;
    case 608:
        import_map_points_from_sdcard();
        break;
    case 609:
        // run yaml tests
        new Thread() {
            public void run() {
                try {
                    ZANaviDebugReceiver.DR_run_all_yaml_tests();
                } catch (Exception e) {
                }
            }
        }.start();
        break;
    case 99:
        try {
            if (wl_navigating != null) {
                //if (wl_navigating.isHeld())
                //{
                wl_navigating.release();
                Log.e("Navit", "WakeLock Nav: release 1");
                //}
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        // exit
        this.onPause();
        this.onStop();
        this.exit();
        //msg = new Message();
        //b = new Bundle();
        //b.putInt("Callback", 5);
        //b.putString("cmd", "quit();");
        //msg.setData(b);
        //N_NavitGraphics.callback_handler.sendMessage(msg);
        break;
    }
    return true;
}