I want to run intent navigation in the application, now I have a problem:

in the absence of a GoogleНавигация application. GoogleНавигация on the phone, the application crashes.

How to add a condition so that in the absence of the above application, for example, a Toast message is displayed indicating that there is no navigation application?

 button_navi.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent33 = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("google.navigation:q=Россия+Самара+Ленина+34")); startActivity(intent33); } }); 

    2 answers 2

    You can also check for the presence of Google Maps in this way:

     public boolean isGoogleMapsInstalled() { try { ApplicationInfo info = getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0 ); return true; } catch(PackageManager.NameNotFoundException e) { return false; } } 
       if (intent.resolveActivity(getPackageManager()) != null) startActivityForResult(intent, 0); else ... 

      https://stackoverflow.com/questions/11073832/no-activity-found-to-handle-intent