Search code examples
javaandroidgoogle-mapsnavigationbaidu

Launching Baidu Map intent from custom app


Inside my app I am supplied with a shipment address. And when the user presses a button it launches an intent to google maps with that address as a parameter.

String uri = String.format(Locale.ENGLISH, "google.navigation:q=" + shipmentAdress);
                                                    Intent intent = new Intent(Intent.ACTION_VIEW,
                                                            Uri.parse(uri));
                                                    startActivity(intent);

I would like to do the same thing for our customers in China that do not have access to Google Maps but to Baidu Maps. Keep in mind that I don't have GPS coords, just the address.

Does anyone know how I would go about doing that? All their documentation is in Chinese and so is their app, and I've only gotten so far with Google Translate.

I've got it down to something like "baidumap://map/geocoder?src=openApiDemo&address=" but it usually returns and error (I think, I used screenshots of the error and Pleco's OCR to sort of translate it.)


Solution

  • Figured it out eventually:

    String uri = String.format(Locale.CHINA, "baidumap://map/navi?query=" + shipmentAdress);
    Intent intent = new Intent(Intent.ACTION_VIEW,
    Uri.parse(uri));
    startActivity(intent);