title: How to close google maps app(which started as an intent) programatically?
body: <p>I'm starting the Google Maps app from my app in order to navigate the user to a certain latitude &amp; longitude.</p>
  
  <p>What I want is, I want to close the Google Maps app as soon as user reach the destination (in other words, when user's current location gets equal to destination location).</p>
  
  <p>This is what i have done so far:</p>
  
  <pre><code>Button btnNavigate = (Button) view.findViewById(R.id.btn_navigate);
                  btnNavigate.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                          builder.setMessage(R.string.rtxt);
                          builder.setPositiveButton("Navigate me", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialogInterface, int i) {
                                  Toast.makeText(getActivity(), "Navigating you...", Toast.LENGTH_SHORT).show();
                                  Handler handler = new Handler();
                                  handler.postDelayed(new Runnable() {
                                      @Override
                                      public void run() {
                                          Uri gmmIntentUri = Uri.parse("google.navigation:q=" + currentLatAcceptS + ", " + currentLngAcceptS);
                                          Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
                                          mapIntent.setPackage("com.google.android.apps.maps");
                                          startActivity(mapIntent);
                                      }
                                  }, 1500);
                              }
  
                          });
                          builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialogInterface, int i) {
                                  Toast.makeText(getActivity(), "cancelled", Toast.LENGTH_LONG).show();
                              }
                          });
                          AlertDialog dialog = builder.create();
                          dialog.show();
  
                          cLatDouble = Double.parseDouble(currentLatAcceptS);
                          cLngDouble = Double.parseDouble(currentLngAcceptS);
  
                          if (currentLocation.getLatitude() == cLatDouble &amp;&amp; currentLocation.getLongitude() == cLngDouble){
                              // what to do here so that google maps get closed as soon as user reach the destination?
                          }
  
                      }
                  });
  </code></pre>
  
  <p>Please help me with this.</p>
  
  <p>Please cooperate if the question seems to be badly formatted, I'm still learning to post good questions.</p>