How to set photosphere mode when open panorama Android

后端 未结 1 1025
甜味超标
甜味超标 2021-01-04 07:45

I am stuck with a problem when I want open a photosphere picture with my android application. Indeed, I can open it but the application show a sort of preview of the photosp

1条回答
  •  春和景丽
    2021-01-04 08:04

    Hope the following below helps:

    public class YourActivity extends Activity implements ConnectionCallbacks,
            OnConnectionFailedListener {
    
    private GoogleApiClient gacClient;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gacClient= new GoogleApiClient.Builder(this, this, this)
                .addApi(Panorama.API)
                .build();
    }
    
    @Override
    public void onStart() {
        super.onStart();
        gacClient.connect();
    }
    
    @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() {
            @Override
            public void onResult(PanoramaResult result) {
                Intent i;
                if (result.getStatus().isSuccess() && (i = result.getViewerIntent()) != null) {
                    startActivity(i);
                } else {
                    // Handle unsuccessful result
                }
            }
        });
    }
    
    @Override
    public void onConnectionSuspended(int cause) {
        // Handle connection being suspended
    }
    
    @Override
    public void onConnectionFailed(ConnectionResult status) {
        // Handle connection failure.
    }
    
    @Override
    public void onStop() {
        super.onStop();
        gacClient.disconnect();
    }
    }
    

    Below is a link and example of library to use PhotoSphere without Google+:

    https://github.com/kennydude/photosphere

    Intent i = new Intent(MainActivity.this, SphereViewer.class);
                    i.setData(Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/DCIM/Camera/PANO_20131209_130755.jpg"));
                    startActivity(i);
    

    PhotoSphere uses gyroscope and not accelerometer, however I am sure you can use the second solution and add your own accelerometer functionality.

    0 讨论(0)
提交回复
热议问题