コード例 #1
0
  /** Set POI action buttons */
  private void loadPOIActions() {
    ViewGroup root = (ViewGroup) findViewById(R.id.actionButtonContainer);

    // get the popup objet and add the buttons to the container
    ObjectPopup popup = mPOI.getObjectPopup();
    ObjectButtonVector buttons = popup.getButtons();
    for (int i = 0, j = (int) buttons.size(); i < j; i++) {
      ObjectButton button = buttons.get(i);
      addButton2(button, root);
    }

    // if the routing is enabled, check if we have a navigation intent
    // handler and add a button for navigation
    if (mPOI.isRoutingEnabled()) {
      Intent intent =
          new Intent(
              android.content.Intent.ACTION_VIEW,
              Uri.parse(
                  "google.navigation:q="
                      + mPOI.getLocation().getLatitude()
                      + ","
                      + mPOI.getLocation().getLongitude()));
      List<ResolveInfo> list =
          getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
      if (list.size() > 0) {
        ObjectButton button = new ObjectButton();
        button.setButtonName(getString(R.string.MSG_TITLE_DIRECTIONS));
        button.setButtonValue(
            "google.navigation:q="
                + mPOI.getLocation().getLatitude()
                + ","
                + mPOI.getLocation().getLongitude());
        addButton2(button, root);
      }
    }
  }