Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if a Streetview exists before launching Streetview intent

Launching a Streetview intent for a location doesn't guarantee that a Streetview exists for that location. If the Streetview doesn't exist, the user just sees a black screen that spins. Is there a way to programmatically check if it exists before launching the Streetview intent?

like image 730
Osmund Avatar asked Jan 22 '23 08:01

Osmund


2 Answers

Use PackageManager and queryIntentActivities() with your Intent. If you get back a list of 0 matching activities, you know nothing on the device will handle your request.

like image 121
CommonsWare Avatar answered Jan 30 '23 00:01

CommonsWare


A way to do that would be to use Google Street View Image API to check whether Google Street View exist or not.

https://developers.google.com/maps/documentation/streetview/

It returns an image with a different file size when Street View at a particular co-ordinates exist,than when it doesn't

http://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,%20-73.988354&fov=90&heading=235&pitch=10&sensor=false

You can compare these images and check if it exist or not.

like image 32
shreks7 Avatar answered Jan 30 '23 02:01

shreks7