Example usage for android.os Message setData

List of usage examples for android.os Message setData

Introduction

In this page you can find the example usage for android.os Message setData.

Prototype

public void setData(Bundle data) 

Source Link

Document

Sets a Bundle of arbitrary data values.

Usage

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

public static void write_route_to_gpx_file() {
    final Thread write_route_to_gpx_file_001 = new Thread() {
        int wait = 1;
        int count = 0;
        int max_count = 300; // wait 2 minutes for route to be calculated

        @Override/*from w w  w .  j  a v  a 2s  . co  m*/
        public void run() {
            while (wait == 1) {
                try {
                    if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) {
                        Message msg = new Message();
                        Bundle b = new Bundle();
                        b.putInt("Callback", 96);
                        String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN)
                                .format(new Date());
                        String filename = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_route_" + date + ".gpx";
                        b.putString("s", filename);
                        System.out.println("Debug:" + "file=" + filename);
                        msg.setData(b);
                        NavitGraphics.callback_handler.sendMessage(msg);

                        Message msg7 = Navit_progress_h.obtainMessage();
                        Bundle b7 = new Bundle();
                        msg7.what = 2; // long Toast message
                        b7.putString("text", Navit.get_text("saving route to GPX-file") + " " + filename); //TRANS
                        msg7.setData(b7);
                        Navit_progress_h.sendMessage(msg7);

                        wait = 0;
                    } else {
                        wait = 1;
                    }

                    count++;
                    if (count > max_count) {
                        wait = 0;

                        Message msg7 = Navit_progress_h.obtainMessage();
                        Bundle b7 = new Bundle();
                        msg7.what = 2; // long Toast message
                        b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS
                        msg7.setData(b7);
                        Navit_progress_h.sendMessage(msg7);
                    } else {
                        Thread.sleep(400);
                    }
                } catch (Exception e) {
                }
            }
        }
    };
    write_route_to_gpx_file_001.start();
}

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

static void set_map_position_to_screen_center() {
    try {//from  ww  w  .  ja va  2s.c  o  m
        Message msg = new Message();
        Bundle 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);
    } catch (Exception e) {
    }
}

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

private static void activatePrefs(int dummy) {

    need_recalc_route = false; // do we need to recalc the route?

    // call some functions to activate the new settings
    if (p.PREF_follow_gps) {
        Navit.follow_current = Navit.follow_on;
    } else {//from  ww w  .jav  a  2 s . co  m
        Navit.follow_current = Navit.follow_off;
    }

    if (p.PREF_use_fast_provider) {
        NavitVehicle.turn_on_fast_provider();
    } else {
        NavitVehicle.turn_off_fast_provider();
    }

    if (p.PREF_show_sat_status) {
        NavitVehicle.turn_on_sat_status();
    } else {
        // status always on !
        //
        // NavitVehicle.turn_off_sat_status();
        NavitVehicle.turn_on_sat_status();
    }

    if (p.PREF_show_status_bar) {
        show_status_bar_wrapper();
    } else {
        hide_status_bar_wrapper();
    }

    if (p.PREF_allow_gui_internal) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 10);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 9);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    if (p.PREF_use_compass_heading_base) {
        // turn on compass
        msg_to_msg_handler(new Bundle(), 12);
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 11);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        // turn off compass
        msg_to_msg_handler(new Bundle(), 13);
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 12);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    if (p.PREF_show_maps_debug_view == true) {
        // show real gps pos
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 112);
        b.putString("s", "1");
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 112);
        b.putString("s", "0");
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    if (p.PREF_show_real_gps_pos == 1) {
        // show real gps pos
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 111);
        b.putString("s", "1");
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 111);
        b.putString("s", "0");
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    // search radius for housenumbers near streets -----------------
    Message msg43 = new Message();
    Bundle b43 = new Bundle();
    b43.putInt("Callback", 89);
    b43.putString("s", "1500");
    msg43.setData(b43);
    try {
        NavitGraphics.callback_handler.sendMessage(msg43);
    } catch (Exception e) {
    }
    // search radius for housenumbers near streets -----------------

    // set routing profile -----------------
    if (Navit_Largemap_DonateVersion_Installed == true) {
        Message msg43a = new Message();
        Bundle b43a = new Bundle();
        b43a.putInt("Callback", 90);
        b43a.putString("s", p.PREF_routing_profile); // set routing profile
        msg43a.setData(b43a);
        try {
            NavitGraphics.callback_handler.sendMessage(msg43a);
        } catch (Exception e) {
        }

        // need_recalc_route = true;
    }
    // set routing profile -----------------

    Message msg99a = new Message();
    Bundle b99a = new Bundle();
    b99a.putInt("Callback", 98);
    // System.out.println("tracking_connected_pref=" + PREF_tracking_connected_pref);
    b99a.putString("s", "" + p.PREF_tracking_connected_pref); // set routing profile
    msg99a.setData(b99a);
    try {
        NavitGraphics.callback_handler.sendMessage(msg99a);
    } catch (Exception e) {
    }

    msg99a = new Message();
    b99a = new Bundle();
    b99a.putInt("Callback", 99);
    // System.out.println("tracking_angle_pref=" + PREF_tracking_angle_pref);
    b99a.putString("s", "" + p.PREF_tracking_angle_pref); // set routing profile
    msg99a.setData(b99a);
    try {
        NavitGraphics.callback_handler.sendMessage(msg99a);
    } catch (Exception e) {
    }

    // change road profile -----------------
    if (Navit_Largemap_DonateVersion_Installed == true) {
        if (p.PREF_routing_profile.equals("bike-normal")) {
            Message msg43b = new Message();
            Bundle b43b = new Bundle();
            b43b.putInt("Callback", 91);
            System.out.println("road_priority_001=" + p.PREF_road_priority_001);
            b43b.putString("s", "" + p.PREF_road_priority_001); // set routing profile
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }

            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 92);
            System.out.println("road_priority_002=" + p.PREF_road_priority_002);
            b43b.putString("s", "" + p.PREF_road_priority_002); // set routing profile
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }

            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 93);
            System.out.println("road_priority_003=" + p.PREF_road_priority_003);
            b43b.putString("s", "" + p.PREF_road_priority_003); // set routing profile
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }

            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 94);
            System.out.println("road_priority_004=" + p.PREF_road_priority_004);
            b43b.putString("s", "" + p.PREF_road_priority_004); // set routing profile
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }

            // switch off layers --------------------
            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 60);
            b43b.putString("s", "POI traffic lights");
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }
            // switch off layers --------------------

            // switch ON layers --------------------
            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 59);
            b43b.putString("s", "POI bicycle");
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }
            // switch ON layers --------------------

        } else {
            // switch off layers --------------------
            Message msg43b = new Message();
            Bundle b43b = new Bundle();
            b43b.putInt("Callback", 60);
            b43b.putString("s", "POI bicycle");
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }
            // switch off layers --------------------

            // switch ON layers --------------------
            msg43b = new Message();
            b43b = new Bundle();
            b43b.putInt("Callback", 59);
            b43b.putString("s", "POI traffic lights");
            msg43b.setData(b43b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg43b);
            } catch (Exception e) {
            }
            // switch ON layers --------------------
        }
    } else {
        // switch off layers --------------------
        Message msg43b = new Message();
        Bundle b43b = new Bundle();
        b43b.putInt("Callback", 60);
        b43b.putString("s", "POI bicycle");
        msg43b.setData(b43b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg43b);
        } catch (Exception e) {
        }
        // switch off layers --------------------

        // switch ON layers --------------------
        msg43b = new Message();
        b43b = new Bundle();
        b43b.putInt("Callback", 59);
        b43b.putString("s", "POI traffic lights");
        msg43b.setData(b43b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg43b);
        } catch (Exception e) {
        }
        // switch ON layers --------------------
    }
    // change road profile -----------------

    // -- debug -- change some prio weights --
    //      if ((!p.PREF_routing_profile.equals("bike-normal")) && (!p.PREF_routing_profile.equals("bike-no-oneway")) && (!p.PREF_routing_profile.equals("bike-avoid-roads")))
    //      {
    //         Message msg93 = new Message();
    //         Bundle b93 = new Bundle();
    //         b93.putInt("Callback", 110);
    //         b93.putString("s", "street_1_city#route_prio_weight:" + p.PREF_road_prio_weight_street_1_city);
    //         msg93.setData(b93);
    //         try
    //         {
    //            NavitGraphics.callback_handler.sendMessage(msg93);
    //         }
    //         catch (Exception e)
    //         {
    //         }
    //
    //         if (p_old.PREF_road_prio_weight_street_1_city != p.PREF_road_prio_weight_street_1_city)
    //         {
    //            need_recalc_route = true;
    //         }
    //      }
    // -- debug -- change some prio weights --

    if (NavitGraphics.navit_route_status == 0) {
        if (p.PREF_c_linedrawing) {
            Message msg = new Message();
            Bundle b = new Bundle();
            b.putInt("Callback", 85);
            b.putString("s", "1");
            msg.setData(b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg);
            } catch (Exception e) {
            }
        } else {
            Message msg = new Message();
            Bundle b = new Bundle();
            b.putInt("Callback", 85);
            b.putString("s", "0");
            msg.setData(b);
            try {
                NavitGraphics.callback_handler.sendMessage(msg);
            } catch (Exception e) {
            }
        }
    }

    Message msg33 = new Message();
    Bundle b33 = new Bundle();
    b33.putInt("Callback", 103);
    if (p.PREF_show_vehicle_in_center) {
        b33.putString("s", "0");
    } else {
        b33.putString("s", "" + NavitGraphics.lower_than_center_percent);
    }
    msg33.setData(b33);
    try {
        NavitGraphics.callback_handler.sendMessage(msg33);
    } catch (Exception e88) {
    }

    if (p.PREF_use_imperial) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 16);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 15);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    if (p.PREF_show_debug_messages) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 24);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 25);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    //      if (PREF_show_3d_map)
    //      {
    //         Message msg = new Message();
    //         Bundle b = new Bundle();
    //         b.putInt("Callback", 31);
    //         msg.setData(b);
    //         try
    //         {
    //            N_NavitGraphics.callback_handler.sendMessage(msg);
    //         }
    //         catch (Exception e)
    //         {
    //         }
    //      }
    //      else
    //      {
    //         Message msg = new Message();
    //         Bundle b = new Bundle();
    //         b.putInt("Callback", 30);
    //         msg.setData(b);
    //         try
    //         {
    //            N_NavitGraphics.callback_handler.sendMessage(msg);
    //         }
    //         catch (Exception e)
    //         {
    //         }
    //      }

    if (p.PREF_use_lock_on_roads) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 36);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 37);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    //      if (PREF_draw_polyline_circles)
    //      {
    //         Message msg = new Message();
    //         Bundle b = new Bundle();
    //         b.putString("s", "0");
    //         b.putInt("Callback", 56);
    //         msg.setData(b);
    //         try
    //         {
    //            N_NavitGraphics.callback_handler.sendMessage(msg);
    //         }
    //         catch (Exception e)
    //         {
    //         }
    //      }
    //      else
    //      {
    //         Message msg = new Message();
    //         Bundle b = new Bundle();
    //         b.putString("s", "1");
    //         b.putInt("Callback", 56);
    //         msg.setData(b);
    //         try
    //         {
    //            N_NavitGraphics.callback_handler.sendMessage(msg);
    //         }
    //         catch (Exception e)
    //         {
    //         }
    //      }

    if (p.PREF_use_route_highways) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 42);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 43);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    }

    Message msg7 = new Message();
    Bundle b7 = new Bundle();
    b7.putInt("Callback", 57);
    b7.putString("s", "" + p.PREF_drawatorder);
    msg7.setData(b7);
    try {
        NavitGraphics.callback_handler.sendMessage(msg7);
    } catch (Exception e) {
    }

    msg7 = new Message();
    b7 = new Bundle();
    b7.putInt("Callback", 58);
    b7.putString("s", p.PREF_streetsearch_r);
    msg7.setData(b7);
    try {
        NavitGraphics.callback_handler.sendMessage(msg7);
    } catch (Exception e) {
    }

    if (p.PREF_speak_street_names) {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 54);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }
    } else {
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 53);
        msg.setData(b);
        try {
            NavitGraphics.callback_handler.sendMessage(msg);
        } catch (Exception e) {
        }

    }

    try {
        NavitGraphics.OverlayDrawThread_cancel_drawing_timeout = NavitGraphics.OverlayDrawThread_cancel_drawing_timeout__options[p.PREF_cancel_map_drawing_timeout];
        NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time = NavitGraphics.OverlayDrawThread_cancel_thread_sleep_time__options[p.PREF_cancel_map_drawing_timeout];
        NavitGraphics.OverlayDrawThread_cancel_thread_timeout = NavitGraphics.OverlayDrawThread_cancel_thread_timeout__options[p.PREF_cancel_map_drawing_timeout];
    } catch (Exception e) {

    }

    // route variant
    Message msg67 = new Message();
    Bundle b67 = new Bundle();
    // turn off 1
    b67.putInt("Callback", 60);
    b67.putString("s", "route_001");
    msg67.setData(b67);

    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }
    // turn off 2
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 60);
    b67.putString("s", "route_002");
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }
    // turn off 3
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 60);
    b67.putString("s", "route_003");
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }

    // turn on the wanted route style
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 59);
    b67.putString("s", "route_00" + p.PREF_route_style);
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }
    // route variant

    // show route rectanlges -----
    if (p.PREF_show_route_rects) {
        msg67 = new Message();
        b67 = new Bundle();
        b67.putInt("Callback", 76);
        msg67.setData(b67);
        try {
            NavitGraphics.callback_handler.sendMessage(msg67);
        } catch (Exception e) {
        }
    } else {
        msg67 = new Message();
        b67 = new Bundle();
        b67.putInt("Callback", 77);
        msg67.setData(b67);
        try {
            NavitGraphics.callback_handler.sendMessage(msg67);
        } catch (Exception e) {
        }
    }
    // show route rectanlges -----

    // show route multipolygons -----
    if (p.PREF_show_multipolygons) {
        msg67 = new Message();
        b67 = new Bundle();
        b67.putInt("Callback", 66);
        msg67.setData(b67);
        try {
            NavitGraphics.callback_handler.sendMessage(msg67);
        } catch (Exception e) {
        }
    } else {
        msg67 = new Message();
        b67 = new Bundle();
        b67.putInt("Callback", 67);
        msg67.setData(b67);
        try {
            NavitGraphics.callback_handler.sendMessage(msg67);
        } catch (Exception e) {
        }
    }
    // show route multipolygons -----

    // traffic lights delay ----
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 79);
    //System.out.println("traffic lights delay:" + PREF_trafficlights_delay);
    // (PREF_trafficlights_delay / 10) seconds delay for each traffic light
    b67.putString("s", p.PREF_trafficlights_delay); // (delay in 1/10 of a second)
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }
    // traffic lights delay ----

    // avoid sharp turns ----
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 86);
    b67.putString("s", p.PREF_avoid_sharp_turns);
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }

    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 87);
    b67.putString("s", "47"); // **DANGER** sharp turn max angle hardcoded here!! **DANGER**
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }

    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 88);
    b67.putString("s", "6000");
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {
    }
    // avoid sharp turns ----

    // autozoom flag ----
    msg67 = new Message();
    b67 = new Bundle();
    b67.putInt("Callback", 80);
    if (p.PREF_autozoom_flag) {
        b67.putString("s", "1"); // (0 or 1)
    } else {
        b67.putString("s", "0"); // (0 or 1)         
    }
    msg67.setData(b67);
    try {
        NavitGraphics.callback_handler.sendMessage(msg67);
    } catch (Exception e) {

    }
    // autozoom flag ----

    if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed)) {
        // use pref
    } else {
        p.PREF_roadspeed_warning = false;
    }

    if ((Navit.Navit_Largemap_DonateVersion_Installed) || (Navit.Navit_DonateVersion_Installed)) {
        // use pref
    } else {
        p.PREF_lane_assist = false;
    }

    if (p.PREF_streets_only) {
        // ----------------------- streets only pref -------------------
        // 59 -> enable
        // 60 -> disable
        Message msg31 = new Message();
        Bundle b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "polygons001");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "polygons");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "POI Symbols");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "POI Labels");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "Android-POI-Icons-full");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "Android-POI-Labels-full");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets_1");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets_2");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets_1_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets_2_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);
        // ----------------------- streets only pref -------------------
    } else {
        // ----------------------- streets only pref -------------------
        // 59 -> enable
        // 60 -> disable
        Message msg31 = new Message();
        Bundle b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "polygons001");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "polygons");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "POI Symbols");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "POI Labels");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "Android-POI-Icons-full");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "Android-POI-Labels-full");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets_1");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 59);
        b31.putString("s", "streets_2");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets_1_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);

        msg31 = new Message();
        b31 = new Bundle();
        b31.putInt("Callback", 60);
        b31.putString("s", "streets_2_STR_ONLY");
        msg31.setData(b31);
        NavitGraphics.callback_handler.sendMessage(msg31);
        // ----------------------- streets only pref -------------------
    }

    // ---------- set traffic factor for road speeds ------------
    try {
        Message msg_ss1 = new Message();
        Bundle b_ss1 = new Bundle();
        b_ss1.putInt("Callback", 106);
        b_ss1.putString("s", Integer.toString(p.PREF_traffic_speed_factor));
        msg_ss1.setData(b_ss1);
        NavitGraphics.callback_handler.sendMessage(msg_ss1);
    } catch (Exception e) {
    }
    // ---------- set traffic factor for road speeds ------------

    // ------- PREF_show_poi_on_map ---------------------------------
    set_poi_layers();
    // ------- PREF_show_poi_on_map ---------------------------------

    set_TurnRestrictions_layers();

    // set vars for mapdir change (only really takes effect after restart!)
    getPrefs_mapdir();

    if (need_recalc_route) {
        recalculate_route();
        need_recalc_route = false;
    }

}

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

public void zoom_out_full() {
    // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);

    System.out.println("");
    System.out.println("*** Zoom out FULL ***");
    System.out.println("");
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 8);
    msg.setData(b);
    NavitGraphics.callback_handler.sendMessage(msg);

    // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);
}

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

void convert_gpx_file_real(String gpx_file) {
    File tt2 = new File(gpx_file);
    p.PREF_last_selected_dir_gpxfiles = tt2.getParent();
    Log.e("Navit", "last_selected_dir_gpxfiles " + p.PREF_last_selected_dir_gpxfiles);
    setPrefs_selected_gpx_dir();/*from ww w .j a va 2s. c o  m*/

    String out_ = MAP_FILENAME_PATH + "/gpxtracks.txt";
    Log.e("Navit", "onActivityResult 002 " + gpx_file + " " + out_);
    MainFrame.do_conversion(gpx_file, out_);

    // draw map no-async
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 64);
    msg.setData(b);
    NavitGraphics.callback_handler.sendMessage(msg);
}

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

public void start_targetsearch_from_intent(String target_address) {
    Navit_last_address_partial_match = true; // this will overwrite the default setting --> this is not good
    Navit_last_address_search_string = target_address;
    Navit_last_address_hn_string = "";

    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    Boolean use_online_searchmode_here = true;
    Boolean hide_duplicates_searchmode_here = false;
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------
    // ----------- CONFIG ---------

    int dialog_num_;

    if (use_online_searchmode_here) {
        dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG;
        Navit.use_index_search = false;//from   w  w  w  . j  a  v a2 s .  com
        Log.e("Navit", "*google*:online search");
    } else {
        dialog_num_ = Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE;
        Navit.use_index_search = Navit.allow_use_index_search();
    }

    // clear results
    Navit.NavitAddressResultList_foundItems.clear();
    Navit.Navit_Address_Result_double_index.clear();
    Navit.NavitSearchresultBarIndex = -1;
    Navit.NavitSearchresultBar_title = "";
    Navit.NavitSearchresultBar_text = "";
    search_hide_duplicates = false;

    if (Navit_last_address_search_string.equals("")) {
        // empty search string entered
        Toast.makeText(getApplicationContext(), Navit.get_text("No address found"), Toast.LENGTH_LONG).show(); //TRANS
    } else {
        // show dialog
        try {
            Log.e("Navit", "*google*:call-11: (0)num " + dialog_num_);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (hide_duplicates_searchmode_here) {
            search_hide_duplicates = true;
            // hide duplicates when searching
            // hide duplicates when searching
            Message msg22 = new Message();
            Bundle b22 = new Bundle();
            b22.putInt("Callback", 45);
            msg22.setData(b22);
            NavitGraphics.callback_handler.sendMessage(msg22);
            // hide duplicates when searching
            // hide duplicates when searching
        }

        System.out.println("dialog -- 11:002");
        Message msg = progress_handler.obtainMessage();
        Bundle b = new Bundle();
        msg.what = 11;
        b.putInt("dialog_num", dialog_num_);
        msg.setData(b);
        progress_handler.sendMessage(msg);
    }
}

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

@TargetApi(Build.VERSION_CODES.FROYO)
@Override//from  ww w. j  a  v a 2  s .  c o  m
public void onPause() {

    // if COMM stuff is running, stop it!
    ZANaviDebugReceiver.stop_me = true;

    // hide main progress bar ------------
    if (Navit.progressbar_main_activity.getVisibility() == View.VISIBLE) {
        Navit.progressbar_main_activity.setProgress(0);
        Navit.progressbar_main_activity.setVisibility(View.GONE);
    }
    // hide main progress bar ------------

    try {
        sensorManager.unregisterListener(lightSensorEventListener);
    } catch (Exception e) {
    }

    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----
    // -- dump all callbacks --
    try {
        if (p.PREF_enable_debug_functions) {
            Message msg99a = new Message();
            Bundle b99a = new Bundle();
            b99a.putInt("Callback", 100);
            msg99a.setData(b99a);
            N_NavitGraphics.callback_handler.sendMessage(msg99a);
        }
    } catch (Exception e) {
    }
    // -- dump all callbacks --
    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----

    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----
    try {
        if (!Navit.is_navigating) {
            if (p.PREF_enable_debug_write_gpx) {
                NavitVehicle.pos_recording_end();
            }
        }
    } catch (Exception e) {
    }
    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----

    // System.out.println("@@ onPause @@");
    Log.e("Navit", "OnPause");
    try {
        setPrefs_zoomlevel();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        watchmem.stop_me();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        //watchmem.join();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        //Simulate.stop_me();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        //Simulate.join();
    } catch (Exception e) {
        e.printStackTrace();
    }

    Navit.show_mem_used();

    //      if (!Navit.is_navigating)
    //      {
    //         try
    //         {
    //            mTts.stop();
    //         }
    //         catch (Exception e)
    //         {
    //
    //         }
    //
    //         try
    //         {
    //            mTts.shutdown();
    //         }
    //         catch (Exception e)
    //         {
    //
    //         }
    //
    //         mTts = null;
    //      }

    super.onPause();

    // signal to backupmanager that data "is / could have" changed
    try {
        Class.forName("android.app.backup.BackupManager");
        BackupManager b = (BackupManager) backupManager;
        b.dataChanged();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    turn_off_compass();

    // System.out.println("XXNAV: onpause:001");
    if (!Navit.is_navigating) {
        // System.out.println("XXNAV: onpause:002");
        NavitVehicle.turn_off_all_providers();
        NavitVehicle.turn_off_sat_status();
        // System.out.println("XXNAV: onpause:003");
    }

    // Log.e("Navit", "OnPause");
    cwthr.NavitActivity2(-1);

    Navit.show_mem_used();

    try {
        if (wl != null) {
            wl.release();
            Log.e("Navit", "WakeLock: release 1");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        if (wl_cpu != null) {
            if (wl_cpu.isHeld()) {
                wl_cpu.release();
                Log.e("Navit", "WakeLock CPU: release 1");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // glSurfaceView.onPause();

    is_paused = true;
}

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

@TargetApi(Build.VERSION_CODES.FROYO)
protected Dialog onCreateDialog(int id) {

    System.out.println("onCreateDialog id=" + id);

    switch (id) {
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    // ==============---------- real search offline (old style) here ----------==============
    case Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE:
        search_results_wait_offline = new ProgressDialog(this);
        search_results_wait_offline.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait_offline.setTitle("--");
        search_results_wait_offline.setMessage("--");
        search_results_wait_offline.setCancelable(true); // allow to stop search
        search_results_wait_offline.setProgress(0);
        search_results_wait_offline.setMax(10);

        search_results_wait_offline.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                Message msg = new Message();
                Bundle b = new Bundle();
                b.putInt("Callback", 46);
                msg.setData(b);
                try {
                    NavitGraphics.callback_handler.sendMessage(msg);
                } catch (Exception e) {
                }/*from   w w  w.  ja va  2 s  .  c om*/
                Log.e("Navit", "onCancel: search_results_wait offline");
            }
        });

        /*
         * search_results_wait.setButton("stop", new DialogInterface.OnClickListener()
         * {
         * public void onClick(DialogInterface dialog, int which)
         * {
         * // Use either finish() or return() to either close the activity or just the dialog
         * return;
         * }
         * });
         */

        DialogInterface.OnDismissListener mOnDismissListener4 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait offline");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread_offline.stop_me();
            }
        };
        search_results_wait_offline.setOnDismissListener(mOnDismissListener4);
        System.out.println("new SearchResultsThread 001");
        searchresultsThread_offline = new SearchResultsThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        searchresultsThread_offline.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread_offline = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE);
        spinner_thread_offline.start();

        return search_results_wait_offline;
    case Navit.SEARCHRESULTS_WAIT_DIALOG:
        search_results_wait = new ProgressDialog(this);
        search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        search_results_wait.setTitle("--");
        search_results_wait.setMessage("--");
        search_results_wait.setCancelable(false);
        search_results_wait.setProgress(0);
        search_results_wait.setMax(10);

        DialogInterface.OnDismissListener mOnDismissListener3 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: search_results_wait");
                dialog.dismiss();
                dialog.cancel();
                searchresultsThread.stop_me();
            }
        };
        search_results_wait.setOnDismissListener(mOnDismissListener3);
        System.out.println("new SearchResultsThread 002");
        searchresultsThread = new SearchResultsThread(progress_handler, Navit.SEARCHRESULTS_WAIT_DIALOG);
        searchresultsThread.start();

        NavitAddressSearchSpinnerActive = true;
        spinner_thread = new SearchResultsThreadSpinnerThread(progress_handler,
                Navit.SEARCHRESULTS_WAIT_DIALOG);
        spinner_thread.start();

        return search_results_wait;
    case Navit.MAPDOWNLOAD_PRI_DIALOG:
        mapdownloader_dialog_pri = new ProgressDialog(this);
        mapdownloader_dialog_pri.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_pri.setTitle("--");
        mapdownloader_dialog_pri.setMessage("--");
        mapdownloader_dialog_pri.setCancelable(false);
        mapdownloader_dialog_pri.setCanceledOnTouchOutside(false);
        mapdownloader_dialog_pri.setProgress(0);
        mapdownloader_dialog_pri.setMax(200);

        WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow().getAttributes();
        dialog_lparams.screenBrightness = 0.1f;
        mapdownloader_dialog_pri.getWindow().setAttributes(dialog_lparams);

        DialogInterface.OnDismissListener mOnDismissListener1 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                android.view.WindowManager.LayoutParams dialog_lparams = mapdownloader_dialog_pri.getWindow()
                        .getAttributes();
                mapdownloader_dialog_pri.getWindow().setAttributes((WindowManager.LayoutParams) dialog_lparams);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
                mapdownloader_dialog_pri.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                Log.e("Navit", "onDismiss: mapdownloader_dialog pri");
                dialog.dismiss();
                dialog.cancel();
                progressThread_pri.stop_thread();
            }
        };

        try {
            mapdownloader_dialog_pri.setButton(AlertDialog.BUTTON_NEGATIVE, Navit.get_text("Cancel"),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            mapdownloader_dialog_pri.dismiss();
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }

        mapdownloader_dialog_pri.setOnDismissListener(mOnDismissListener1);
        mapdownloader_pri = new NavitMapDownloader(this);
        progressThread_pri = mapdownloader_pri.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_PRIMARY);
        progressThread_pri.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_pri;
    case Navit.MAPDOWNLOAD_SEC_DIALOG:
        mapdownloader_dialog_sec = new ProgressDialog(this);
        mapdownloader_dialog_sec.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mapdownloader_dialog_sec.setTitle("--");
        mapdownloader_dialog_sec.setMessage("--");

        mapdownloader_dialog_sec.setCancelable(true);
        mapdownloader_dialog_sec.setProgress(0);
        mapdownloader_dialog_sec.setMax(200);
        DialogInterface.OnDismissListener mOnDismissListener2 = new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                Log.e("Navit", "onDismiss: mapdownloader_dialog sec");
                dialog.dismiss();
                dialog.cancel();
                progressThread_sec.stop_thread();
            }
        };
        mapdownloader_dialog_sec.setOnDismissListener(mOnDismissListener2);
        mapdownloader_sec = new NavitMapDownloader(this);
        progressThread_sec = mapdownloader_sec.new ProgressThread(progress_handler,
                NavitMapDownloader.z_OSM_MAPS[Navit.download_map_id], MAP_NUM_SECONDARY);
        progressThread_sec.start();
        //
        // show license for OSM maps
        //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english
        Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT)
                .show(); //TRANS
        return mapdownloader_dialog_sec;
    }
    // should never get here!!
    return null;
}

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

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressLint("NewApi")
@Override//w  w  w  . j av  a  2  s .c  om
public boolean onOptionsItemSelected(MenuItem item) {
    //System.out.println("menu button pressed ID=" + item.getItemId());

    if ((item.getItemId() == R.id.share_menu_destination)
            || (item.getItemId() == R.id.overflow_share_destination) || (item.getItemId() == 23020)) {
        // System.out.println("share destination pressed ID=" + item.getItemId());
        // ------------
        // ------------
        // 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!");
            }
        }
        return true;
    } else if (item.getItemId() == R.id.item_download_menu_button) {
        // System.out.println("download icon pressed(1) ID=" + item.getItemId());

        Intent mapdownload_cancel_activity = new Intent(this, ZANaviDownloadMapCancelActivity.class);
        mapdownload_cancel_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        startActivity(mapdownload_cancel_activity);

        return true;
    } else if ((item.getItemId() == R.id.share_menu_location)
            || (item.getItemId() == R.id.overflow_share_location) || (item.getItemId() == 23000)) {
        // System.out.println("share location pressed ID=" + item.getItemId());
        // ------------
        // ------------
        // share the current location with your friends
        location_coords cur_target = new location_coords();
        try {
            geo_coord tmp = get_current_vehicle_position();
            cur_target.lat = tmp.Latitude;
            cur_target.lon = tmp.Longitude;

            if ((cur_target.lat == 0.0) && (cur_target.lon == 0.0)) {
                cur_target = NavitVehicle.get_last_known_pos();
            }
        } catch (Exception e) {
            cur_target = null;
            try {
                cur_target = NavitVehicle.get_last_known_pos();
            } catch (Exception e2) {
                cur_target = null;
            }
        }

        if (cur_target == null) {
            Log.e("Navit", "no location found!");
        } else {
            try {
                share_location(String.valueOf(cur_target.lat), String.valueOf(cur_target.lon),
                        Navit.get_text("my Location"), Navit.get_text("my Location"), "", false);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Navit", "problem with location!");
            }
        }
        return true;
    } else if ((item.getItemId() == R.id.item_settings_menu_button)
            || (item.getItemId() == R.id.overflow_settings) || (item.getItemId() == 490)) {
        // open settings menu
        Intent settingsActivity = new Intent(getBaseContext(), NavitPreferences.class);
        startActivity(settingsActivity);

        return true;
    } else if (item.getItemId() == R.id.search_menu_offline) {
        // 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);

        Navit.use_index_search = Navit.allow_use_index_search();
        if (Navit.use_index_search) {
            this.startActivityForResult(search_intent2, NavitAddressResultList_id);
        } else {
            this.startActivityForResult(search_intent2, NavitAddressSearch_id_offline);
        }

        return true;
    } else if (item.getItemId() == R.id.search_menu_online) {
        // 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);

        return true;
    } else if (item.getItemId() == R.id.item_endnavigation_menu_button) {
        // stop navigation (this menu should only appear when navigation is actually on!)
        NavitGraphics.deactivate_nav_wakelock();
        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");

        if (p.PREF_enable_debug_write_gpx) {
            NavitVehicle.speech_recording_end();
        }

        // redraw all OSD elements
        Navit.OSD_route_001.arriving_time_valid = false;
        Navit.OSD_route_001.arriving_secs_to_dest_valid = false;
        Navit.OSD_route_001.driving_distance_to_target_valid = false;
        Navit.OSD_nextturn.nextturn_distance_valid = false;
        Navit.OSD_nextturn.nextturn_image_valid = false;
        Navit.OSD_compass.direct_distance_to_target_valid = false;
        NavitGraphics.OSD_new.postInvalidate();

        return true;
    } else if (item.getItemId() == R.id.item_recentdest_menu_button) {
        // show recent destination list
        Intent i2 = new Intent(this, NavitRecentDestinationActivity.class);
        this.startActivityForResult(i2, Navit.NavitRecentDest_id);

        return true;
    } else if (item.getItemId() == R.id.overflow_zoom_to_route) {
        return onOptionsItemSelected_wrapper(11);
    } else if (item.getItemId() == R.id.overflow_donate_item) {
        return onOptionsItemSelected_wrapper(26);
    } else if (item.getItemId() == R.id.overflow_donate_bitcoins_item) {
        return onOptionsItemSelected_wrapper(27);
    } else if (item.getItemId() == R.id.overflow_exit) {
        return onOptionsItemSelected_wrapper(99);
    } else if (item.getItemId() == R.id.overflow_toggle_poi) {
        return onOptionsItemSelected_wrapper(5);
    } else if (item.getItemId() == R.id.overflow_announcer_on) {
        return onOptionsItemSelected_wrapper(13);
    } else if (item.getItemId() == R.id.overflow_announcer_off) {
        return onOptionsItemSelected_wrapper(12);
    } else if (item.getItemId() == R.id.overflow_download_maps) {
        return onOptionsItemSelected_wrapper(3);
    } else if (item.getItemId() == R.id.overflow_delete_maps) {
        return onOptionsItemSelected_wrapper(8);
    } else if (item.getItemId() == R.id.overflow_maps_age) {
        return onOptionsItemSelected_wrapper(17);
    } else if (item.getItemId() == R.id.overflow_coord_dialog) {
        return onOptionsItemSelected_wrapper(19);
    } else if (item.getItemId() == R.id.overflow_add_traffic_block) {
        return onOptionsItemSelected_wrapper(21);
    } else if (item.getItemId() == R.id.overflow_clear_traffic_block) {
        return onOptionsItemSelected_wrapper(22);
    } else if (item.getItemId() == R.id.overflow_convert_gpx_file) {
        return onOptionsItemSelected_wrapper(20);
    } else if (item.getItemId() == R.id.overflow_clear_gpx_map) {
        return onOptionsItemSelected_wrapper(23);
    } else if (item.getItemId() == R.id.overflow_replay_gps_file) {
        return onOptionsItemSelected_wrapper(28);
    } else if (item.getItemId() == R.id.overflow_yaml_tests) {
        return onOptionsItemSelected_wrapper(609);
    } else if (item.getItemId() == R.id.overflow_demo_v_normal) {
        return onOptionsItemSelected_wrapper(601);
    } else if (item.getItemId() == R.id.overflow_demo_v_fast) {
        return onOptionsItemSelected_wrapper(604);
    } else if (item.getItemId() == R.id.overflow_speech_texts) {
        return onOptionsItemSelected_wrapper(602);
    } else if (item.getItemId() == R.id.overflow_nav_commands) {
        return onOptionsItemSelected_wrapper(603);
    } else if (item.getItemId() == R.id.overflow_toggle_route_graph) {
        return onOptionsItemSelected_wrapper(605);
    } else if (item.getItemId() == R.id.overflow_export_map_points_to_sdcard) {
        return onOptionsItemSelected_wrapper(607);
    } else if (item.getItemId() == R.id.overflow_import_map_points_from_sdcard) {
        return onOptionsItemSelected_wrapper(608);
    } else if (item.getItemId() == R.id.overflow_send_feedback) {
        return onOptionsItemSelected_wrapper(24);
    } else if (item.getItemId() == R.id.overflow_online_help) {
        return onOptionsItemSelected_wrapper(16);
    } else if (item.getItemId() == R.id.overflow_about) {
        return onOptionsItemSelected_wrapper(29);
    } else if (item.getItemId() == R.id.overflow_target_in_gmaps) {
        return onOptionsItemSelected_wrapper(15);
    }
    //      else
    //      {
    //         return onOptionsItemSelected_wrapper(item.getItemId());
    //      }

    return false;
}

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

protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    try {// w w  w .ja  va 2s.co m
        System.out.println("XXIIXX(2):111");
        String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");

        System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);

        if (mid_str != null) {
            if (mid_str.equals("201:UPDATE-APP")) {
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
            } else if (mid_str.startsWith("202:UPDATE-MAP:")) {
                // System.out.println("need to update1:" + mid_str);
                // System.out.println("need to update2:" + mid_str.substring(15));

                auto_start_update_map(mid_str.substring(15));
            }
        }

        System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("XXIIXX(2):111:EEEE");
    }

    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    try {
        System.out.println("XXIIXX(2):" + intent);
        Bundle bundle77 = intent.getExtras();
        System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags()));
        if (bundle77 == null) {
            System.out.println("XXIIXX(2):" + "null");
        } else {
            for (String key : bundle77.keySet()) {
                Object value = bundle77.get(key);
                System.out.println("XXIIXX(2):"
                        + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
            }
        }
    } catch (Exception ee22) {
        String exst = Log.getStackTraceString(ee22);
        System.out.println("XXIIXX(2):ERR:" + exst);
    }
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----

    Log.e("Navit", "3:**1**A " + intent.getAction());
    Log.e("Navit", "3:**1**D " + intent.getDataString());
    Log.e("Navit", "3:**1**S " + intent.toString());
    try {
        Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents());
    } catch (Exception ee3) {
    }

    // if (Navit.startup_intent == null)
    {
        try {
            // make a copy of the given intent object
            // Navit.startup_intent = intent.cloneFilter();
            Navit.startup_intent = intent;

            Log.e("Navit", "3a:**1**001");
            Bundle extras2 = intent.getExtras();
            Log.e("Navit", "3a:**1**002");
            try {
                Navit.startup_intent.putExtras(extras2);
                Log.e("Navit", "3a:**1**003");
            } catch (Exception e4) {
                if (startup_intent.getDataString() != null) {
                    // we have a "geo:" thingy intent, use it
                    // or "gpx file"
                    Log.e("Navit", "3c:**1**A " + startup_intent.getAction());
                    Log.e("Navit", "3c:**1**D " + startup_intent.getDataString());
                    Log.e("Navit", "3c:**1**S " + startup_intent.toString());
                } else {
                    Log.e("Navit", "3X:**1**X ");
                    Navit.startup_intent = null;
                }

                // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
                Navit.startup_intent_timestamp = System.currentTimeMillis();

                return;
            }

            // Intent { act=android.intent.action.VIEW
            // cat=[android.intent.category.DEFAULT]
            // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
            // cmp=com.zoffcc.applications.zanavi/.Navit }

            // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
            Navit.startup_intent_timestamp = System.currentTimeMillis();
            Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
            Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
            Log.e("Navit", "3a:**1**S " + startup_intent.toString());
            if (extras2 != null) {
                long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
                // System.out.println("DH:a007 l=" + l);
                if (l != 0L) {
                    if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) {
                        // Log.e("Navit", "2:**1** started via drive home");
                        // we have been called from "drive home" widget

                        // drive home

                        // check if we have a home location
                        int home_id = find_home_point();

                        if (home_id != -1) {
                            Message msg7 = progress_handler.obtainMessage();
                            Bundle b7 = new Bundle();
                            msg7.what = 2; // long Toast message
                            b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
                            msg7.setData(b7);
                            progress_handler.sendMessage(msg7);

                            // clear any previous destinations
                            Message msg2 = new Message();
                            Bundle b2 = new Bundle();
                            b2.putInt("Callback", 7);
                            msg2.setData(b2);
                            NavitGraphics.callback_handler.sendMessage(msg2);

                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            //               Message msg67 = new Message();
                            //               Bundle b67 = new Bundle();
                            //               b67.putInt("Callback", 51);
                            //               b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
                            //               b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
                            //               msg67.setData(b67);
                            //               N_NavitGraphics.callback_handler.sendMessage(msg67);
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------

                            try {
                                Thread.sleep(60);
                            } catch (Exception e) {
                            }

                            route_wrapper(map_points.get(home_id).point_name, 0, 0, false,
                                    map_points.get(home_id).lat, map_points.get(home_id).lon, true);

                            //                        Navit.destination_set();
                            //
                            //                        // set destination to home location
                            //                        String lat = String.valueOf(map_points.get(home_id).lat);
                            //                        String lon = String.valueOf(map_points.get(home_id).lon);
                            //                        String q = map_points.get(home_id).point_name;
                            //
                            //                        // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
                            //
                            //                        Message msg55 = new Message();
                            //                        Bundle b55 = new Bundle();
                            //                        b55.putInt("Callback", 3);
                            //                        b55.putString("lat", lat);
                            //                        b55.putString("lon", lon);
                            //                        b55.putString("q", q);
                            //                        msg55.setData(b55);
                            //                        NavitGraphics.callback_handler.sendMessage(msg55);

                            final Thread zoom_to_route_001 = new Thread() {
                                int wait = 1;
                                int count = 0;
                                int max_count = 60;

                                @Override
                                public void run() {
                                    while (wait == 1) {
                                        try {
                                            if ((NavitGraphics.navit_route_status == 17)
                                                    || (NavitGraphics.navit_route_status == 33)) {
                                                zoom_to_route();
                                                wait = 0;
                                            } else {
                                                wait = 1;
                                            }

                                            count++;
                                            if (count > max_count) {
                                                wait = 0;
                                            } else {
                                                Thread.sleep(400);
                                            }
                                        } catch (Exception e) {
                                        }
                                    }
                                }
                            };
                            zoom_to_route_001.start();

                            //               try
                            //               {
                            //                  show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
                            //               }
                            //               catch (Exception e2)
                            //               {
                            //                  e2.printStackTrace();
                            //               }

                            try {
                                Navit.follow_button_on();
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        } else {
                            // no home location set
                            Message msg = progress_handler.obtainMessage();
                            Bundle b = new Bundle();
                            msg.what = 2; // long Toast message
                            b.putString("text", Navit.get_text("No Home Location set")); //TRANS
                            msg.setData(b);
                            progress_handler.sendMessage(msg);
                        }

                    }
                } else {
                    if (startup_intent.getDataString() != null) {
                        // we have a "geo:" thingy intent, use it
                        // or "gpx file"
                    } else {
                        Navit.startup_intent = null;
                    }
                }
            } else {
                if (startup_intent.getDataString() != null) {
                    // we have a "geo:" thingy intent, use it
                } else {
                    Navit.startup_intent = null;
                }
            }
        } catch (Exception e99) {
            Navit.startup_intent = null;
        }

    }

}