Example usage for android.content Intent FLAG_ACTIVITY_SINGLE_TOP

List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP

Introduction

In this page you can find the example usage for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.

Prototype

int FLAG_ACTIVITY_SINGLE_TOP

To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.

Click Source Link

Document

If set, the activity will not be launched if it is already running at the top of the history stack.

Usage

From source file:me.spadival.podmode.PodModeService.java

private void localBroadcast(boolean launchMainActivity) {
    Intent localIntent = new Intent(MainActivity.BANNER);
    localIntent.putExtra("banner", mBanner);
    if (!mSongTitle.equals("")) {
        localIntent.putExtra("songname", mSongTitle);
        localIntent.putExtra("albumarturi", mAlbumArtUri);
    }//  www  .  ja  va 2 s . c  o m

    if (launchMainActivity) {
        Intent launchIntent = new Intent(getBaseContext(), MainActivity.class);
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

        getApplication().startActivity(launchIntent);
    }

    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}

From source file:com.instiwork.RegistrationActivity.java

public void login_User(final String URL) {

    if (pDialogOut != null) {
        pDialogOut.show();//from   w  w w . j  a v  a 2s.  co m
    }

    Logger.showMessage(TAG, "OutSide login_User" + URL);
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, URL, null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Logger.showMessage(TAG, "Inside login_User" + URL);
                    Logger.showMessage(TAG, response.toString());
                    Logger.showMessage(TAG, imgPath);

                    ll_image_selection.setEnabled(true);
                    txt_terms_conditions.setEnabled(true);
                    findViewById(R.id.footer).setEnabled(true);
                    findViewById(R.id.help_password).setEnabled(true);
                    findViewById(R.id.help_dob).setEnabled(true);
                    findViewById(R.id.help_license).setEnabled(true);

                    ll_license.setEnabled(true);
                    findViewById(R.id.loginBttn).setEnabled(true);
                    findViewById(R.id.fb_log).setEnabled(true);
                    dateOfBirth.setEnabled(true);
                    ll_image_selection.setClickable(true);
                    txt_terms_conditions.setClickable(true);
                    findViewById(R.id.footer).setClickable(true);
                    findViewById(R.id.help_password).setClickable(true);
                    findViewById(R.id.help_dob).setClickable(true);
                    findViewById(R.id.help_license).setClickable(true);

                    ll_license.setClickable(true);
                    findViewById(R.id.loginBttn).setClickable(true);
                    findViewById(R.id.fb_log).setClickable(true);
                    dateOfBirth.setClickable(true);

                    try {
                        InstiworkApplication.getInstance().setSelectedLicenseArray(null);
                        if (response.getString("status").equalsIgnoreCase("Success")) {

                            SharedPreferences.Editor edit = appSharedPref.edit();
                            edit.putString("USER_ID", response.getJSONObject("details").getString("userid"));
                            try {
                                edit.putString("CURRENCY_ID",
                                        response.getJSONObject("details").getString("currency_id"));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            edit.commit();

                            InstiworkApplication.getInstance()
                                    .setUSER_ID(response.getJSONObject("details").getString("userid"));
                            InstiworkApplication.getInstance()
                                    .setUSER_NAME(response.getJSONObject("details").getString("name"));
                            InstiworkApplication.getInstance().setCOMPANY_NAME(
                                    response.getJSONObject("details").getString("companyname"));
                            InstiworkApplication.getInstance()
                                    .setUSER_EMAIL(response.getJSONObject("details").getString("email"));
                            InstiworkApplication.getInstance()
                                    .setMOBILE_NO(response.getJSONObject("details").getString("contact"));
                            try {
                                InstiworkApplication.getInstance().setJOB_SEARCH_RADIUS(
                                        response.getJSONObject("details").getString("distance"));
                                InstiworkApplication.getInstance()
                                        .setUnit_user(response.getJSONObject("details").getString("unit"));
                            } catch (Exception e) {
                                try {
                                    InstiworkApplication.getInstance().setJOB_SEARCH_RADIUS(
                                            response.getJSONObject("details").getString("distance_user"));
                                    InstiworkApplication.getInstance().setUnit_user(
                                            response.getJSONObject("details").getString("unit_user"));
                                } catch (Exception ex) {
                                    ex.printStackTrace();
                                }
                            }

                            try {
                                InstiworkApplication.getInstance().setPush_status(
                                        response.getJSONObject("details").getString("push_status"));
                                InstiworkApplication.getInstance().setEmail_status(
                                        response.getJSONObject("details").getString("email_status"));
                                InstiworkApplication.getInstance().setText_status(
                                        response.getJSONObject("details").getString("text_status"));
                                InstiworkApplication.getInstance().setCountryid(
                                        response.getJSONObject("details").getString("country_id"));
                                InstiworkApplication.getInstance().setCurrency_id(
                                        response.getJSONObject("details").getString("currency_id"));
                                InstiworkApplication.getInstance().setCountry_name(
                                        response.getJSONObject("details").getString("country_name"));
                                InstiworkApplication.getInstance().setCountry_3_code(
                                        response.getJSONObject("details").getString("country_3_code"));
                                InstiworkApplication.getInstance().setCountry_2_code(
                                        response.getJSONObject("details").getString("country_2_code"));
                                InstiworkApplication.getInstance().setCurrency_code(
                                        response.getJSONObject("details").getString("currency_code"));
                                InstiworkApplication.getInstance().setCurrency_name(
                                        response.getJSONObject("details").getString("currency_name"));
                                InstiworkApplication.getInstance().setMember_since(
                                        response.getJSONObject("details").getString("member_since"));

                            } catch (Exception e) {
                                Logger.showMessage(TAG, "Extra Paremeter : " + e.toString());
                            }

                            try {
                                licenseLinkedList = new LinkedList<JSONObject>();
                                if (response.getJSONObject("details").getJSONArray("license").length() > 0) {
                                    for (int i = 0; i < response.getJSONObject("details")
                                            .getJSONArray("license").length(); i++) {
                                        licenseLinkedList.add(response.getJSONObject("details")
                                                .getJSONArray("license").getJSONObject(i));
                                    }
                                    InstiworkApplication.getInstance().setLicenseArray(licenseLinkedList);
                                } else {
                                    InstiworkApplication.getInstance().setLicenseArray(null);
                                }
                            } catch (Exception e) {
                                InstiworkApplication.getInstance().setLicenseArray(null);
                                Logger.showMessage(TAG, "license Exception" + e.toString());
                            }

                            try {
                                Map<String, Object> params = new HashMap<>();
                                params.put("action", "registration");
                                params.put("action_user_id", InstiworkApplication.getInstance().getUSER_ID());
                                params.put("action_user_name",
                                        InstiworkApplication.getInstance().getUSER_NAME());
                                params.put("action_device", "android");
                                AdWordsRemarketingReporter.reportWithConversionId(getApplicationContext(),
                                        getResources().getString(R.string.conversion_id), params);
                            } catch (Exception e) {
                                Logger.showMessage(TAG, "AdWords : " + e.toString());
                            }

                            if (imgPath.equalsIgnoreCase("")) {
                                if (pDialogOut != null) {
                                    pDialogOut.dismiss();
                                }
                                Toast.makeText(RegistrationActivity.this, "Registered successfully",
                                        Toast.LENGTH_SHORT).show();

                                InstiworkApplication.getInstance()
                                        .setUSER_IMG("" + R.drawable.placeholder_circuler);
                                Intent i = new Intent(getApplicationContext(), LandingActivity.class);
                                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
                                        | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                                startActivity(i);
                                finish();
                            } else {
                                if (pDialogOut != null) {
                                    pDialogOut.show();
                                }
                                String imgUploadUrl = InstiworkConstants.URL_DOMAIN
                                        + "Signup_ios/add_user_image?user_id="
                                        + response.getJSONObject("details").getString("userid");
                                (new UpdateAccountDetailsWithImage(imgPath, imgUploadUrl))
                                        .executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
                            }
                        } else {
                            pDialogOut.dismiss();

                            try {
                                displayMessage(response.getString("details"));
                            } catch (Exception e) {
                                e.printStackTrace();
                                try {
                                    displayMessage(response.getString("message"));
                                } catch (Exception ee) {
                                    ee.printStackTrace();
                                }
                            }

                            //Toast.makeText(RegistrationActivity.this, response.getString("message"), Toast.LENGTH_SHORT).show();
                            //                                Snackbar.make(findViewById(android.R.id.content), response.getString("details"), Snackbar.LENGTH_LONG)
                            //                                        .setActionTextColor(Color.RED)
                            //                                        .show();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Logger.showMessage(TAG, "Vollllllllll Error: " + error.getMessage());
                    pDialogOut.hide();

                    ll_image_selection.setEnabled(true);
                    txt_terms_conditions.setEnabled(true);
                    findViewById(R.id.footer).setEnabled(true);
                    findViewById(R.id.help_password).setEnabled(true);
                    findViewById(R.id.help_dob).setEnabled(true);
                    findViewById(R.id.help_license).setEnabled(true);

                    ll_license.setEnabled(true);
                    findViewById(R.id.loginBttn).setEnabled(true);
                    findViewById(R.id.fb_log).setEnabled(true);
                    dateOfBirth.setEnabled(true);
                    ll_image_selection.setClickable(true);
                    txt_terms_conditions.setClickable(true);
                    findViewById(R.id.footer).setClickable(true);
                    findViewById(R.id.help_password).setClickable(true);
                    findViewById(R.id.help_dob).setClickable(true);
                    findViewById(R.id.help_license).setClickable(true);

                    ll_license.setClickable(true);
                    findViewById(R.id.loginBttn).setClickable(true);
                    findViewById(R.id.fb_log).setClickable(true);
                    dateOfBirth.setClickable(true);

                    if (error instanceof NoConnectionError) {
                        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(
                                RegistrationActivity.this);
                        builder.setTitle("Instiwork");
                        builder.setMessage("You do not have internet connection!");
                        builder.setPositiveButton("retry", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.dismiss();

                                pDialogOut.show();

                                ll_image_selection.setEnabled(false);
                                txt_terms_conditions.setEnabled(false);
                                findViewById(R.id.footer).setEnabled(false);
                                findViewById(R.id.help_password).setEnabled(false);
                                findViewById(R.id.help_dob).setEnabled(false);
                                findViewById(R.id.help_license).setEnabled(false);

                                ll_license.setEnabled(false);
                                findViewById(R.id.loginBttn).setEnabled(false);
                                findViewById(R.id.fb_log).setEnabled(false);
                                dateOfBirth.setEnabled(false);
                                ll_image_selection.setClickable(false);
                                txt_terms_conditions.setClickable(false);
                                findViewById(R.id.footer).setClickable(false);
                                findViewById(R.id.help_password).setClickable(false);
                                findViewById(R.id.help_dob).setClickable(false);
                                findViewById(R.id.help_license).setClickable(false);

                                ll_license.setClickable(false);
                                findViewById(R.id.loginBttn).setClickable(false);
                                findViewById(R.id.fb_log).setClickable(false);
                                dateOfBirth.setClickable(false);

                                login_User(URL);
                            }
                        });
                        builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.dismiss();
                            }
                        });
                        builder.setCancelable(false);
                        builder.show();
                    } else {
                        String json = null;
                        NetworkResponse response = error.networkResponse;
                        if (response != null && response.data != null) {
                            json = new String(response.data);
                            json = trimMessage(json, "message");
                            if (json != null)
                                //                            displayMessage(json);
                                displayMessage(json + " Error Code : " + response.statusCode);
                        }
                    }
                }
            });
    jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(30000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    InstiworkApplication.getInstance().addToRequestQueue(jsonObjReq);
}

From source file:com.linkbubble.ui.ContentView.java

private void configureArticleModeButton() {
    ArticleContent articleContent = mWebRenderer.getArticleContent();
    if (articleContent != null) {
        if (mArticleNotificationId == -1 && TextUtils.isEmpty(articleContent.mText) == false
                && Settings.get().getArticleModeOnWearEnabled()) {
            mArticleNotificationId = sNextArticleNotificationId;
            sNextArticleNotificationId++;

            String title = MainApplication.sTitleHashMap != null
                    ? MainApplication.sTitleHashMap.get(articleContent.mUrl.toString())
                    : "Open Bubble";

            Context context = getContext();

            Intent closeTabIntent = new Intent(context, NotificationCloseTabActivity.class);
            closeTabIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            closeTabIntent.putExtra(NotificationCloseTabActivity.EXTRA_DISMISS_NOTIFICATION,
                    mArticleNotificationId);
            PendingIntent closeTabPendingIntent = PendingIntent.getActivity(context, mArticleNotificationId,
                    closeTabIntent, PendingIntent.FLAG_UPDATE_CURRENT);

            Intent openTabIntent = new Intent(context, NotificationOpenTabActivity.class);
            openTabIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                    | Intent.FLAG_ACTIVITY_NEW_TASK);
            openTabIntent.putExtra(NotificationOpenTabActivity.EXTRA_DISMISS_NOTIFICATION,
                    mArticleNotificationId);
            PendingIntent openTabPendingIntent = PendingIntent.getActivity(context,
                    (int) System.currentTimeMillis(), openTabIntent, PendingIntent.FLAG_UPDATE_CURRENT);

            Notification notification = new NotificationCompat.Builder(context)
                    .addAction(R.drawable.ic_action_cancel_white, context.getString(R.string.action_close_tab),
                            closeTabPendingIntent)
                    .setContentTitle(title).setContentText(articleContent.mText)
                    .setSmallIcon(R.drawable.ic_launcher).setGroup(Constant.NOTIFICATION_GROUP_KEY_ARTICLES)
                    .setContentIntent(openTabPendingIntent).build();

            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
            notificationManager.notify(mArticleNotificationId, notification);
        }//www .  j  a  v a 2 s .com

        if (Settings.get().getArticleModeEnabled()) {
            mArticleModeButton.setVisibility(VISIBLE);
        } else {
            mArticleModeButton.setVisibility(GONE);
        }
    } else {
        mArticleModeButton.setVisibility(GONE);
        if (mArticleRenderer != null) {
            mArticleRenderer.stopLoading();
        }
        cancelWearNotification();
    }
}

From source file:im.vector.activity.VectorRoomActivity.java

/**
 * the room has been joined//  www.  j  a va2 s . c  om
 */
private void onJoined() {
    if (null != sRoomPreviewData) {
        HashMap<String, Object> params = new HashMap<>();

        params.put(VectorRoomActivity.EXTRA_MATRIX_ID, mSession.getMyUserId());
        params.put(VectorRoomActivity.EXTRA_ROOM_ID, sRoomPreviewData.getRoomId());

        if (null != sRoomPreviewData.getEventId()) {
            params.put(VectorRoomActivity.EXTRA_EVENT_ID, sRoomPreviewData.getEventId());
        }

        // clear the activity stack to home activity
        Intent intent = new Intent(VectorRoomActivity.this, VectorHomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);

        intent.putExtra(VectorHomeActivity.EXTRA_JUMP_TO_ROOM_PARAMS, params);
        VectorRoomActivity.this.startActivity(intent);

        sRoomPreviewData = null;
    }
}

From source file:com.linkbubble.ui.ContentView.java

private boolean openInBrowser(String urlAsString, boolean canShowUndoPrompt) {
    Log.d(TAG, "ContentView.openInBrowser() - url:" + urlAsString);
    CrashTracking.log("ContentView.openInBrowser()");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(urlAsString));
    intent.setFlags(//w w w.  j a  v a2  s  .c  o  m
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    if (MainApplication.openInBrowser(getContext(), intent, true) && MainController.get() != null
            && mOwnerTabView != null) {
        // L_WATCH: L currently lacks getRecentTasks(), so minimize here
        MainController.get().switchToBubbleView();
        MainController.get().closeTab(mOwnerTabView, MainController.get().contentViewShowing(),
                canShowUndoPrompt);

        return true;
    }

    return false;
}

From source file:im.neon.activity.VectorRoomActivity.java

/**
 * the room has been joined/*  ww w.  j  av  a2s.  c  o  m*/
 */
private void onJoined() {
    if (null != sRoomPreviewData) {
        HashMap<String, Object> params = new HashMap<>();

        processDirectMessageRoom();

        params.put(VectorRoomActivity.EXTRA_MATRIX_ID, mSession.getMyUserId());
        params.put(VectorRoomActivity.EXTRA_ROOM_ID, sRoomPreviewData.getRoomId());

        if (null != sRoomPreviewData.getEventId()) {
            params.put(VectorRoomActivity.EXTRA_EVENT_ID, sRoomPreviewData.getEventId());
        }

        // clear the activity stack to home activity
        Intent intent = new Intent(VectorRoomActivity.this, VectorHomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);

        intent.putExtra(VectorHomeActivity.EXTRA_JUMP_TO_ROOM_PARAMS, params);
        VectorRoomActivity.this.startActivity(intent);

        sRoomPreviewData = null;
    }
}

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

@SuppressLint("NewApi")
@Override// w  ww  . j a va2s.  c o m
public void onResume() {
    // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);

    // System.gc();
    super.onResume();

    //      // --- alive timestamp ---
    //      app_status_lastalive = System.currentTimeMillis();
    //      System.out.println("app_status_string set:[onResume]:app_status_lastalive=" + app_status_lastalive);
    //      PreferenceManager.getDefaultSharedPreferences(this).edit().putLong(PREF_KEY_LASTALIVE, app_status_lastalive).commit();
    //      // --- alive timestamp ---

    // 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.registerListener(lightSensorEventListener, lightSensor, (int) (8 * 1000000)); // updates approx. every 8 seconds
    } catch (Exception e) {
    }

    // get the intent fresh !! ----------
    startup_intent = this.getIntent();
    // get the intent fresh !! ----------

    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    try {
        intro_flag_nomaps = false;
        if (!have_maps_installed()) {
            if ((!NavitMapDownloader.download_active) && (!NavitMapDownloader.download_active_start)) {
                intro_flag_nomaps = true;
            }
        }
    } catch (Exception e) {
    }

    try {
        intro_flag_indexmissing = false;
        allow_use_index_search();
        if (Navit_index_on_but_no_idx_files) {
            if (!NavitMapDownloader.download_active_start) {
                intro_flag_indexmissing = true;
            }
        }

    } catch (Exception e) {
    }

    intro_flag_firststart = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PREF_KEY_FIRST_START,
            true);
    if (intro_flag_firststart) {
        intro_flag_update = false;
    }

    if (EasyPermissions.hasPermissions(this, perms)) {
        // have permissions!
        intro_flag_permissions = false;
    } else {
        // ask for permissions
        intro_flag_permissions = true;
    }

    // only show in onCreate() ------
    //      if (intro_show_count > 0)
    //      {
    //         intro_flag_info = false;
    //         intro_flag_firststart = false;
    //         intro_flag_update = false;
    //      }
    // only show in onCreate() ------

    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------

    // -------------- INTRO --------------
    // -------------- INTRO --------------
    // -------------- INTRO --------------
    if (Navit.CIDEBUG == 0) // -MAT-INTRO-
    {
        //         intro_flag_nomaps = true;
        //         intro_flag_info = true;
        //         intro_flag_firststart = false;
        //         intro_flag_update = false;
        //         intro_flag_indexmissing = false;
        //        intro_flag_crash = true;

        if (intro_flag_crash || intro_flag_firststart || intro_flag_indexmissing || intro_flag_info
                || intro_flag_nomaps || intro_flag_permissions || intro_flag_update) {

            System.out.println("flags=" + "intro_flag_crash:" + intro_flag_crash + " intro_flag_firststart:"
                    + intro_flag_firststart + " intro_flag_indexmissing:" + intro_flag_indexmissing
                    + " intro_flag_info:" + intro_flag_info + " intro_flag_nomaps:" + intro_flag_nomaps
                    + " intro_flag_permissions:" + intro_flag_permissions + " intro_flag_update:"
                    + intro_flag_update);

            // intro pages
            System.out.println("ZANaviMainIntroActivity:" + "start count=" + intro_show_count);
            intro_show_count++;
            Intent intent = new Intent(this, ZANaviMainIntroActivityStatic.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivityForResult(intent, ZANaviIntro_id);
        }
    }
    //      // -------------- INTRO --------------
    //      // -------------- INTRO --------------
    //      // -------------- INTRO --------------

    PackageInfo pkgInfo;
    Navit_Plugin_001_Installed = false;
    try {
        // is the donate version installed?
        pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_msg", 0);
        String sharedUserId = pkgInfo.sharedUserId;
        System.out.println("str nd=" + sharedUserId);
        if (sharedUserId.equals("com.zoffcc.applications.zanavi")) {
            System.out.println("##plugin 001##");
            Navit_Plugin_001_Installed = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----

    try {
        System.out.println("XXIIXX:111");
        String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
        System.out.println("XXIIXX: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:111b:mid_str=" + mid_str);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("XXIIXX:111:EEEE");
    }

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

    is_paused = false;

    Navit_doubleBackToExitPressedOnce = false;

    app_window = getWindow();

    Log.e("Navit", "OnResume");

    while (Global_Init_Finished == 0) {
        Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
        try {
            Thread.sleep(30, 0); // sleep
        } catch (InterruptedException e) {
        }
    }

    //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    cwthr.NavitActivity2(1);

    try {
        NSp.resume_me();
    } catch (Exception e) {
        e.printStackTrace();
    }

    NavitVehicle.turn_on_sat_status();

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

    //Intent caller = this.getIntent();
    //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
    //System.out.println("C=" + caller.getComponent().flattenToString());

    if (unsupported) {
        class CustomListener implements View.OnClickListener {
            private final Dialog dialog;

            public CustomListener(Dialog dialog) {
                this.dialog = dialog;
            }

            @Override
            public void onClick(View v) {

                // Do whatever you want here

                // If you want to close the dialog, uncomment the line below
                //dialog.dismiss();
            }
        }

        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle("WeltBild Tablet");
        dialog.setCancelable(false);
        dialog.setMessage("Your device is not supported!");
        dialog.show();
        //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
        //theButton.setOnClickListener(new CustomListener(dialog));
    }

    // reset "maps too old" flag
    Navit_maps_too_old = false;

    if (Navit_maps_loaded == false) {
        Navit_maps_loaded = true;
        // activate all maps
        Log.e("Navit", "**** LOAD ALL MAPS **** start");
        Message msg3 = new Message();
        Bundle b3 = new Bundle();
        b3.putInt("Callback", 20);
        msg3.setData(b3);
        NavitGraphics.callback_handler.sendMessage(msg3);
        Log.e("Navit", "**** LOAD ALL MAPS **** end");
    }

    try {
        NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);

        //         if (!have_maps_installed())
        //         {
        //            // System.out.println("MMMM=no maps installed");
        //            // show semi transparent box "no maps installed" ------------------
        //            // show semi transparent box "no maps installed" ------------------
        //            NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
        //            try
        //            {
        //               NavitGraphics.no_maps_container.setActivated(true);
        //            }
        //            catch (NoSuchMethodError e)
        //            {
        //            }
        //
        //            show_case_001();
        //
        //            // show semi transparent box "no maps installed" ------------------
        //            // show semi transparent box "no maps installed" ------------------
        //         }
        //         else
        //         {
        //            NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
        //            try
        //            {
        //               NavitGraphics.no_maps_container.setActivated(false);
        //            }
        //            catch (NoSuchMethodError e)
        //            {
        //            }
        //         }
    } catch (Exception e) {
        e.printStackTrace();
    }

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

    String intent_data = null;
    try {
        //Log.e("Navit", "**9**A " + startup_intent.getAction());
        //Log.e("Navit", "**9**D " + startup_intent.getDataString());

        int type = 1; // default = assume it's a map coords intent

        try {
            String si = startup_intent.getDataString();
            String tmp2 = si.split(":", 2)[0];
            Log.e("Navit", "**9a**A " + startup_intent.getAction());
            Log.e("Navit", "**9a**D " + startup_intent.getDataString() + " " + tmp2);
            if (tmp2.equals("file")) {
                Log.e("Navit", "**9b**D " + startup_intent.getDataString() + " " + tmp2);
                if (si.toLowerCase().endsWith(".gpx")) {
                    Log.e("Navit", "**9c**D " + startup_intent.getDataString() + " " + tmp2);
                    type = 4;
                }
            }
        } catch (Exception e2) {
        }

        if (type != 4) {
            Bundle extras = startup_intent.getExtras();
            // System.out.println("DH:001");
            if (extras != null) {
                // System.out.println("DH:002");
                long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
                // System.out.println("DH:003 l=" + l);
                if (l != 0L) {
                    // System.out.println("DH:004");
                    if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) {
                        // System.out.println("DH:005");
                        type = 2; // call from drive-home-widget
                    }
                    // ok, now remove that key
                    extras.remove("com.zoffcc.applications.zanavi");
                    startup_intent.replaceExtras((Bundle) null);
                    // System.out.println("DH:006");
                }
            }
        }

        // ------------------------  BIG LOOP  ------------------------
        // ------------------------  BIG LOOP  ------------------------
        if (type == 2) {
            // 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) {
                }

                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;
                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);

                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 (type == 4) {

            if (startup_intent != null) {
                // Log.e("Navit", "**7**A " + startup_intent.getAction() + System.currentTimeMillis() + " " + Navit.startup_intent_timestamp);
                if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) {
                    Log.e("Navit", "**7**A " + startup_intent.getAction());
                    Log.e("Navit", "**7**D " + startup_intent.getDataString());
                    intent_data = startup_intent.getDataString();
                    try {
                        intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    // we consumed the intent, so reset timestamp value to avoid double consuming of event
                    Navit.startup_intent_timestamp = 0L;

                    if (intent_data != null) {
                        // file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
                        String tmp1;
                        tmp1 = intent_data.split(":", 2)[1].substring(2);

                        Log.e("Navit", "**7**f=" + tmp1);

                        // convert gpx file ---------------------
                        convert_gpx_file_real(tmp1);
                    }
                }
            }
        } else if (type == 1) {
            if (startup_intent != null) {
                if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) {
                    Log.e("Navit", "**2**A " + startup_intent.getAction());
                    Log.e("Navit", "**2**D " + startup_intent.getDataString());
                    intent_data = startup_intent.getDataString();
                    // we consumed the intent, so reset timestamp value to avoid double consuming of event
                    Navit.startup_intent_timestamp = 0L;

                    if (intent_data != null) {
                        // 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 -----------------------
                    }
                } else {
                    Log.e("Navit", "timestamp for navigate_to expired! not using data");
                }
            }

            System.out.println("SUI:000a " + intent_data);

            if ((intent_data != null) && ((substring_without_ioobe(intent_data, 0, 18)
                    .equals("google.navigation:"))
                    || (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
                    || (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/")))) {

                System.out.println("SUI:000b");

                // better use regex later, but for now to test this feature its ok :-)
                // better use regex later, but for now to test this feature its ok :-)

                // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
                // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
                // b: google.navigation:q=48.25676,16.643
                // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
                // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
                //    sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
                //            -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
                // f: google.navigation:ll=48.25676,16.643&...
                // c: google.navigation:ll=48.25676,16.643
                // h: http://maps.google.com/?q=48.222210,16.387058&z=16
                // i: https://maps.google.com/?q=48.222210,16.387058&z=16
                // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
                //
                // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb

                String lat;
                String lon;
                String q;

                String temp1 = null;
                String temp2 = null;
                String temp3 = null;
                boolean parsable = false;
                boolean unparsable_info_box = true;
                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }

                // DEBUG
                // DEBUG
                // DEBUG
                // intent_data = "google.navigation:q=Wien Burggasse 27";
                // intent_data = "google.navigation:q=48.25676,16.643";
                // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
                // intent_data = "google.navigation:ll=48.25676,16.643";
                // DEBUG
                // DEBUG
                // DEBUG

                try {
                    Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
                    Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
                    Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
                    Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
                    Log.e("Navit", "found DEBUG 4.1: yy"
                            + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
                    Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
                } catch (Exception e) {
                    e.printStackTrace();
                }

                if (!Navit.NavitStartupAlreadySearching) {
                    if (intent_data.length() > 19) {
                        // if h: then show target
                        if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/")) {
                            Uri uri = Uri.parse(intent_data);
                            Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
                            parsable = true;
                            intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
                        }
                        // if i: then show target
                        else if (substring_without_ioobe(intent_data, 0, 24)
                                .equals("https://maps.google.com/")) {
                            Uri uri = Uri.parse(intent_data);
                            Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
                            parsable = true;
                            intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
                        }
                        // if d: then start target search
                        else if ((substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
                                && ((!substring_without_ioobe(intent_data, 20, 21).equals('+'))
                                        && (!substring_without_ioobe(intent_data, 20, 21).equals('-'))
                                        && (!substring_without_ioobe(intent_data, 20, 22)
                                                .matches("[0-9][0-9]")))) {
                            Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
                            Navit.NavitStartupAlreadySearching = true;
                            start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
                            // dont use this here, already starting search, so set to "false"
                            parsable = false;
                            unparsable_info_box = false;
                        }
                        // if b: then remodel the input string to look like a:
                        else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q=")) {
                            intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
                            Log.e("Navit", "target found (b): " + intent_data);
                            parsable = true;
                        }
                        // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
                        else if (substring_without_ioobe(intent_data, 0, 25)
                                .equals("google.navigation:///?ll=")) {
                            intent_data = "google.navigation:ll="
                                    + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
                            Log.e("Navit", "target found (g): " + intent_data);
                            parsable = true;
                        }
                        // if e: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&").length > 1)
                                && (substring_without_ioobe(intent_data.split("&")[1], 0, 1).toLowerCase()
                                        .equals("f"))) {
                            int idx = intent_data.indexOf("&");
                            intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
                            Log.e("Navit", "target found (e): " + intent_data);
                            parsable = true;
                        }
                        // if f: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&").length > 1)) {
                            int idx = intent_data.indexOf("&");
                            intent_data = intent_data.substring(0, idx) + "&q=Target";
                            Log.e("Navit", "target found (f): " + intent_data);
                            parsable = true;
                        }
                        // already looks like a: just set flag
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&q=").length > 1)) {
                            // dummy, just set the flag
                            Log.e("Navit", "target found (a): " + intent_data);
                            Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
                            parsable = true;
                        }
                        // if c: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&q=").length < 2)) {

                            intent_data = intent_data + "&q=Target";
                            Log.e("Navit", "target found (c): " + intent_data);
                            parsable = true;
                        }
                    }
                } else {
                    Log.e("Navit", "already started search from startup intent");
                    parsable = false;
                    unparsable_info_box = false;
                }

                if (parsable) {
                    // now string should be in form --> a:
                    // now split the parts off
                    temp1 = intent_data.split("&q=", -1)[0];
                    try {
                        temp3 = temp1.split("ll=", -1)[1];
                        temp2 = intent_data.split("&q=", -1)[1];
                    } catch (Exception e) {
                        // java.lang.ArrayIndexOutOfBoundsException most likely
                        // so let's assume we dont have '&q=xxxx'
                        temp3 = temp1;
                    }

                    if (temp2 == null) {
                        // use some default name
                        temp2 = "Target";
                    }

                    lat = temp3.split(",", -1)[0];
                    lon = temp3.split(",", -1)[1];
                    q = temp2;
                    // is the "search name" url-encoded? i think so, lets url-decode it here
                    q = URLDecoder.decode(q);
                    // System.out.println();

                    Navit.remember_destination(q, lat, lon);
                    Navit.destination_set();

                    Message msg = new Message();
                    Bundle b = new Bundle();
                    b.putInt("Callback", 3);
                    b.putString("lat", lat);
                    b.putString("lon", lon);
                    b.putString("q", q);
                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);

                    final Thread zoom_to_route_002 = 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_002.start();

                    //                  try
                    //                  {
                    //                     Thread.sleep(400);
                    //                  }
                    //                  catch (InterruptedException e)
                    //                  {
                    //                  }
                    //
                    //                  //                  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 {
                    if (unparsable_info_box && !searchBoxShown) {
                        try {
                            searchBoxShown = true;
                            String searchString = intent_data.split("q=")[1];
                            searchString = searchString.split("&")[0];
                            searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
                            Log.e("Navit", "Search String :" + searchString);
                            executeSearch(searchString);
                        } catch (Exception e) {
                            // safety net
                            try {
                                Log.e("Navit", "problem with startup search 7 str=" + intent_data);
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        }
                    }
                }
            } else if ((intent_data != null)
                    && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q="))) {
                // g: geo:0,0?q=wien%20burggasse

                System.out.println("SUI:001");

                boolean parsable = false;
                boolean unparsable_info_box = true;
                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();

                }

                System.out.println("SUI:002");

                if (!Navit.NavitStartupAlreadySearching) {
                    if (intent_data.length() > 10) {
                        // if g: then start target search
                        Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
                        Navit.NavitStartupAlreadySearching = true;
                        start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
                        // dont use this here, already starting search, so set to "false"
                        parsable = false;
                        unparsable_info_box = false;
                    }
                } else {
                    Log.e("Navit", "already started search from startup intent");
                    parsable = false;
                    unparsable_info_box = false;
                }

                if (unparsable_info_box && !searchBoxShown) {
                    try {
                        searchBoxShown = true;
                        String searchString = intent_data.split("q=")[1];
                        searchString = searchString.split("&")[0];
                        searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
                        Log.e("Navit", "Search String :" + searchString);
                        executeSearch(searchString);
                    } catch (Exception e) {
                        // safety net
                        try {
                            Log.e("Navit", "problem with startup search 88 str=" + intent_data);
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }
                    }
                }

            } else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:"))) {
                // g: geo:16.8,46.3?z=15

                System.out.println("SUI:002a");

                boolean parsable = false;
                boolean unparsable_info_box = true;

                String tmp1;
                String tmp2;
                String tmp3;
                float lat1 = 0;
                float lon1 = 0;
                int zoom1 = 15;

                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }

                if (!Navit.NavitStartupAlreadySearching) {
                    try {
                        tmp1 = intent_data.split(":", 2)[1];
                        tmp2 = tmp1.split("\\?", 2)[0];
                        tmp3 = tmp1.split("\\?", 2)[1];
                        lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
                        lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
                        zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
                        parsable = true;
                    } catch (Exception e4) {
                        e4.printStackTrace();
                    }
                }

                if (parsable) {
                    // geo: intent -> only show destination on map!

                    // set nice zoomlevel before we show destination
                    //                  int zoom_want = zoom1;
                    //                  //
                    //                  Message msg = new Message();
                    //                  Bundle b = new Bundle();
                    //                  b.putInt("Callback", 33);
                    //                  b.putString("s", Integer.toString(zoom_want));
                    //                  msg.setData(b);
                    //                  try
                    //                  {
                    //                     N_NavitGraphics.callback_handler.sendMessage(msg);
                    //                     Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
                    //                     if ((zoom_want > 8) && (zoom_want < 17))
                    //                     {
                    //                        Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
                    //                        System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
                    //                     }
                    //                  }
                    //                  catch (Exception e)
                    //                  {
                    //                     e.printStackTrace();
                    //                  }
                    //                  if (PREF_save_zoomlevel)
                    //                  {
                    //                     setPrefs_zoomlevel();
                    //                  }
                    // set nice zoomlevel before we show destination

                    try {
                        Navit.follow_button_off();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }

                    show_geo_on_screen(lat1, lon1);
                    //                  final Thread zoom_to_route_003 = new Thread()
                    //                  {
                    //                     @Override
                    //                     public void run()
                    //                     {
                    //                        try
                    //                        {
                    //                           Thread.sleep(200);
                    //                           show_geo_on_screen(lat1, lon1);
                    //                        }
                    //                        catch (Exception e)
                    //                        {
                    //                        }
                    //                     }
                    //                  };
                    //                  zoom_to_route_003.start();

                }
            }
        }

        System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");

        // clear intent
        startup_intent = null;
        // ------------------------  BIG LOOP  ------------------------
        // ------------------------  BIG LOOP  ------------------------
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("SUI:199");
    }

    // clear intent
    startup_intent = null;

    // hold all map drawing -----------
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 69);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // hold all map drawing -----------

    getPrefs();
    activatePrefs();
    sun_moon__mLastCalcSunMillis = -1L;

    push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
    if (p.PREF_follow_gps) {
        push_pin_view.setImageResource(R.drawable.pin1_down);
    } else {
        push_pin_view.setImageResource(R.drawable.pin1_up);
    }

    // paint for bitmapdrawing on map
    if (p.PREF_use_anti_aliasing) {
        NavitGraphics.paint_for_map_display.setAntiAlias(true);
    } else {
        NavitGraphics.paint_for_map_display.setAntiAlias(false);
    }
    if (p.PREF_use_map_filtering) {
        NavitGraphics.paint_for_map_display.setFilterBitmap(true);
    } else {
        NavitGraphics.paint_for_map_display.setFilterBitmap(false);
    }

    // activate gps AFTER 3g-location
    NavitVehicle.turn_on_precise_provider();

    // allow all map drawing -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 70);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // allow all map drawing -----------

    // --- disabled --- NavitVehicle.set_last_known_pos_fast_provider();

    try {
        //Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
        //Simulate.start();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        watchmem = new WatchMem();
        watchmem.start();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // ----- check if we have some index files downloaded -----

    if (api_version_int < 11) {
        if (Navit.have_maps_installed()) {
            if (Navit_maps_too_old) {
                TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
                no_maps_text.setText("\n\n\n" + Navit.get_text("Some Maps are too old!") + "\n"
                        + Navit.get_text("Please update your maps") + "\n\n");

                try {
                    NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
                    try {
                        NavitGraphics.no_maps_container.setActivated(true);
                    } catch (NoSuchMethodError e) {
                    }
                    NavitGraphics.no_maps_container.bringToFront();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                allow_use_index_search();
                if (Navit_index_on_but_no_idx_files) {
                    TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
                    no_maps_text.setText("\n\n\n" + Navit.get_text("No Index for some Maps") + "\n"
                            + Navit.get_text("Please update your maps") + "\n\n");

                    try {
                        NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
                        try {
                            NavitGraphics.no_maps_container.setActivated(true);
                        } catch (NoSuchMethodError e) {
                        }
                        NavitGraphics.no_maps_container.bringToFront();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
                        try {
                            NavitGraphics.no_maps_container.setActivated(false);
                        } catch (NoSuchMethodError e) {
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    } else {
        try {
            NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
            try {
                NavitGraphics.no_maps_container.setActivated(false);
            } catch (NoSuchMethodError e) {
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // ----- check if we have some index files downloaded -----

    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----
    try {
        if (!NavitVehicle.is_pos_recording) {
            if (p.PREF_enable_debug_write_gpx) {
                NavitVehicle.pos_recording_start();
                NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
            }
        }
    } catch (Exception e) {
    }
    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----

    // glSurfaceView.onResume();

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

    if (Navit.CIDEBUG == 1) {
        new Thread() {
            public void run() {
                try {
                    System.out.println("DR_run_all_yaml_tests --> want");

                    if (CIRUN == false) {
                        System.out.println("DR_run_all_yaml_tests --> do");
                        CIRUN = true;
                        Thread.sleep(20000); // 20 secs.
                        ZANaviDebugReceiver.DR_run_all_yaml_tests();
                    }
                } catch (Exception e) {
                }
            }
        }.start();
    }
}

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

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    ////from   w ww  .  j  av a 2 s .  c  o m
    menu.clear();

    // load the menu from XML
    getMenuInflater().inflate(R.menu.actionbaricons, menu);

    // NavitOverflowMenuItemID = R.id.item_overflow_menu_button;
    menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination"));
    menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location"));
    menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)"));
    menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)"));
    menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations"));
    menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings"));
    menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search"));

    // --- download icon ---
    menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map"));
    // --- download icon ---

    //
    menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location"));
    menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination"));
    menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings"));
    menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route"));

    if (ZANaviNormalDonateActivity.on_amazon_device) {
        menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate"));
    } else {
        menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play"));
    }
    menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin"));
    //. TRANSLATORS: text to translate is: exit ZANavi
    menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit"));
    menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI"));
    menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On"));
    menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off"));
    menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps"));
    menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps"));
    menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age"));
    menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog"));
    menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block"));
    menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks"));
    menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file"));
    menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file"));
    menu.findItem(R.id.overflow_yaml_tests).setTitle(Navit.get_text("run YAML tests"));
    menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map"));
    // menu.findItem(R.id.overflow_dummy2)
    menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]");
    menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]");
    menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts"));
    menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands"));
    menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph"));
    //menu.findItem(R.id.overflow_dummy1)
    menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations"));
    menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations"));
    menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback"));
    menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help"));
    menu.findItem(R.id.overflow_about).setTitle(Navit.get_text("About"));
    //. TRANSLATORS: it means: "show current target in google maps"
    //. TRANSLATORS: please keep this text short, to fit in the android menu!
    menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps"));
    //
    //
    menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share"));

    Display display_ = getWindowManager().getDefaultDisplay();
    Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density);
    Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density);

    try {
        View v4 = findViewById(R.id.item_settings_menu_button);
        // Log.e("Navit", "Navit width in DP -> v4=" + v4);
        if ((v4 != null) && (v4.getWidth() > 0)) {
            Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth());
            MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
            // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
            // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
            Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
            actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f))
                    / 2);
        } else {
            MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
            // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
            // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
            Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
            actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f);
        }

        actionbar_items_will_fit = display_.getWidth() / actionbar_item_width;
        Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit);
        if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar
        {
            actionbar_all_items_will_fit = true;
        } else {
            actionbar_all_items_will_fit = false;
        }
    } catch (Exception e) {
        if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR) {
            actionbar_all_items_will_fit = false;
        } else {
            actionbar_all_items_will_fit = true;
        }
    }

    if (actionbar_all_items_will_fit == false) {
        menu.findItem(R.id.item_share_menu_button).setVisible(false);
        menu.findItem(R.id.overflow_share_location).setVisible(true);
        if (NavitGraphics.CallbackDestinationValid2() == 0) {
            menu.findItem(R.id.overflow_share_destination).setVisible(false);
        } else {
            menu.findItem(R.id.overflow_share_destination).setVisible(true);
        }

        if (actionbar_items_will_fit < 6) {
            // also push the settings icons to overflow menu
            menu.findItem(R.id.item_settings_menu_button).setVisible(false);
            menu.findItem(R.id.overflow_settings).setVisible(true);
        } else {
            menu.findItem(R.id.item_settings_menu_button).setVisible(true);
            menu.findItem(R.id.overflow_settings).setVisible(false);
        }
    } else {
        menu.findItem(R.id.item_settings_menu_button).setVisible(true);
        menu.findItem(R.id.overflow_settings).setVisible(false);
        menu.findItem(R.id.overflow_share_location).setVisible(false);
        menu.findItem(R.id.overflow_share_destination).setVisible(false);
        menu.findItem(R.id.item_share_menu_button).setVisible(true);
    }

    cur_menu = menu;

    System.out.println("down_icon:000");

    try {
        MenuItem downloadViewMenuItem = menu.findItem(R.id.item_download_menu_button);
        System.out.println("down_icon:001");
        downloadViewMenuItem.setVisible(true);
        System.out.println("down_icon:002");
        System.out.println("down_icon:003");
        android.widget.ImageView v = (android.widget.ImageView) MenuItemCompat
                .getActionView(menu.findItem(R.id.item_download_menu_button));
        System.out.println("down_icon:004");
        v.setVisibility(View.VISIBLE);
        if (v != null) {
            System.out.println("down_icon:005");
            v.setImageBitmap(null);
            System.out.println("down_icon:006");

            v.setBackgroundResource(R.drawable.anim_download_icon_2);
            final AnimationDrawable anim = (AnimationDrawable) v.getBackground();

            // ----------------------------------
            // thanks to: http://stackoverflow.com/questions/14686802/animationdrawable-is-not-working-on-2-3-6-android-version
            // ----------------------------------
            v.post(new Runnable() {
                public void run() {
                    try {
                        anim.start();
                        System.out.println("down_icon:006a");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            System.out.println("down_icon:007");

            v.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent mapdownload_cancel_activity = new Intent(Navit.this,
                            ZANaviDownloadMapCancelActivity.class);
                    mapdownload_cancel_activity
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(mapdownload_cancel_activity);
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("down_icon:099:EE");
    }

    if (actionabar_download_icon_visible) {
        menu.findItem(R.id.item_download_menu_button).setVisible(true);
    } else {
        menu.findItem(R.id.item_download_menu_button).setVisible(false);
    }

    if (NavitGraphics.CallbackDestinationValid2() > 0) {
        menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true);
        menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation"));
        menu.findItem(R.id.overflow_zoom_to_route).setVisible(true);
        menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true);
        menu.findItem(R.id.share_menu_destination).setVisible(true);
    } else {
        menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false);
        menu.findItem(R.id.overflow_zoom_to_route).setVisible(false);
        menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false);
        menu.findItem(R.id.share_menu_destination).setVisible(false);
    }

    if (Navit_Announcer == true) {
        menu.findItem(R.id.overflow_announcer_off).setVisible(true);
        menu.findItem(R.id.overflow_announcer_on).setVisible(false);
    } else {
        menu.findItem(R.id.overflow_announcer_off).setVisible(false);
        menu.findItem(R.id.overflow_announcer_on).setVisible(true);
    }

    if (p.PREF_enable_debug_functions) {
        menu.findItem(R.id.overflow_dummy2).setVisible(true);
        menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
        menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
        menu.findItem(R.id.overflow_speech_texts).setVisible(true);
        menu.findItem(R.id.overflow_nav_commands).setVisible(true);
        menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true);
        menu.findItem(R.id.overflow_replay_gps_file).setVisible(true);
        menu.findItem(R.id.overflow_yaml_tests).setVisible(true);
    } else {
        menu.findItem(R.id.overflow_dummy2).setVisible(false);
        menu.findItem(R.id.overflow_demo_v_normal).setVisible(false);
        menu.findItem(R.id.overflow_demo_v_fast).setVisible(false);
        menu.findItem(R.id.overflow_speech_texts).setVisible(false);
        menu.findItem(R.id.overflow_nav_commands).setVisible(false);
        menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false);
        menu.findItem(R.id.overflow_replay_gps_file).setVisible(false);
        menu.findItem(R.id.overflow_yaml_tests).setVisible(false);
    }

    return true;
}

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

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressLint("NewApi")
@Override//from   w w w  . jav a 2s  . 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;
}