title: Android intent chooser - navigation apps
body: <p>In my app I have a button, which opens a Google map with sent coordinates.</p>
  
  <pre><code> final ImageView view = findViewById(R.id.navigate);
          view.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                          Uri.parse("http://maps.google.com/maps?daddr="+gps1+","+gps2));
                  startActivity(intent);
              }
          });
  </code></pre>
  
  <p>This is working fine, but I want to offer to the user all navigation apps that he has in his device after button click.</p>
  
  <p>So not to automatically open Google Maps, but let the user choose which app to use.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/47325631/navigation-with-waze-and-google-maps-using-intent-createchooser-shows-waze-icon">this solution</a>, but this is only for Google maps and Waze. As I can't know which and how many navigation apps the user has on his device, I can't hardcode all existing navigation apps.</p>
  
  <pre><code>String url = "waze://?ll=" + latitude + ", " + longitude + "&amp;navigate=yes";
  Intent intentWaze.setPackage("com.waze");
  Intent intentWaze = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  
  String uriGoogle = "google.navigation:q=" + latitude + "," + longitude;
  Intent intentGoogleNav.setPackage("com.google.android.apps.maps");
  Intent intentGoogleNav = new Intent(Intent.ACTION_VIEW, Uri.parse(uriGoogle));
  
  String title = context.getString(R.string.title);
  Intent chooserIntent = Intent.createChooser(intentGoogleNav, title);
  Intent[] arr = new Intent[1];
  arr[0] = intentWaze;
  chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arr);
  context.startActivity(chooserIntent);
  </code></pre>
  
  <p>So is there any solution, which can offer all navigation apps that the user has?</p>
  
  <p>For example for sharing function it works like this:</p>
  
  <pre><code> Intent sendIntent = new Intent();
                  sendIntent.setAction(Intent.ACTION_SEND);
                  sendIntent.putExtra(Intent.EXTRA_TEXT,
                          infox);
                  sendIntent.setType("text/plain");
                  startActivity(Intent.createChooser(sendIntent, getString(R.string.share)));
  </code></pre>
  
  <p>This will show many apps with sharing possibility. How to do the same for apps with map?</p>
  
  <p>EDIT: I added this to google and waze code, so now I have listed in chooser: Google map, Waze and an unknown android icon, when I click it, it shows all navigation apps on my device! However only if I click that unnamed icon and it only opens those maps without navigation.</p>
  
  <pre><code> String urlx = "geo:" + gps1 + ", " + gps2;
                  Intent intentOther = new Intent(Intent.ACTION_VIEW, Uri.parse(urlx));
  </code></pre>
  
  <p>I need to show all those app immediately after button click.</p>