How to open photosphere via URL from Google Maps in own android app

742 views Asked by At

I'm a rookie android developer. I'm working on app which opens panoramas (photosphere 360 images) directly from google maps not from images stored on device like on example here.

@Override
public void onConnected(Bundle connectionHint) {
Uri uri = Uri.parse("file://" + Environment.getExternalStorageDirectory() +"/DCIM/Camera/PANO_20131209_130755.jpg");

Panorama.PanoramaApi.loadPanoramaInfo(gacClient, uri).setResultCallback(
        new ResultCallback<PanoramaResult>() {
    @Override
    public void onResult(PanoramaResult result) {
        Intent i;
        if (result.getStatus().isSuccess() && (i = result.getViewerIntent()) != null) {
            startActivity(i);
        } else {
            // Handle unsuccessful result
        }
    }
});
}

Just to be clear I use slightly different approach for receiving image - R.drawable.imagename instead of direct path to image, but this is not a case. As I said i wanted to provide a direct link to photosphere from Google Maps via Uri.parse but whitout success. I'm not sure if I missed something crucial here or there is no way to use available photosphere on Google Maps in own app.

Uri uri = Uri.parse("https://www.google.pl/maps/@37.826,-122.421833,3a,75y,275.52h,91.47t/data=!3m8!1e1!3m6!1s-JpUn9Jc8nE4%2FU9WHk3F6ofI%2FAAAAAAAAJmE%2FlpWfb4Rc5x0!2e4!3e11!6s%2F%2Flh4.googleusercontent.com%2F-JpUn9Jc8nE4%2FU9WHk3F6ofI%2FAAAAAAAAJmE%2FlpWfb4Rc5x0%2Fw203-h101-n-k-no%2F!7i10500!8i5250"); 

Thanks in advance for answers or ideas how to deal with it!

1

There are 1 answers

0
SwagBomb On

URI can only take in files, content, or resource. This is stated in the Panorama API documentation

uri - the URI of the panorama to load info about. May be a file:, content:, or android_resource: scheme.

Try parsing the URL of the image itself into the URI.

Uri uri = Uri.parse("imageURL");