Search code examples
javaandroidwaze

ANDROID Integrate my app with Waze


I want to integrate Waze into my android application. I follow the steps from the link below.

https://www.waze.com/about/dev#android_api

I search through the questions and found this same one but it is for ios

xcode and waze integration

Below is the code which i use.

try
            {
                String url = "waze://?q=Hawaii";
                Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(url) );
                startActivity( intent );
            }
            catch ( ActivityNotFoundException ex  )
            {
                Intent intent =
                        new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=com.waze" ) );
                startActivity(intent);
            }

Why I got the following error when I run it?

Process: com.domain.appname, PID: 5711
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.waze }

Solution

  • Change

    market://details?id=com.waze
    

    to

    https://play.google.com/store/apps/details?id=com.waze
    

    you can also add this validation to avoid crash

    intent.resolveActivity(getPackageManager()) != null