How to set photosphere mode when open panorama Android

烂漫一生 提交于 2019-11-30 02:09:29

问题


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 photosphere (it scrolls the picture from left to right). I want that my application open the photosphere with the acceloremeter mode (the mode that we need to turn the phone to show the entire picture) without clicking the button at the bottom right.

I use that code to open the panorama :

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName("com.google.android.gms", "com.google.android.gms.panorama.PanoramaViewActivity"));
intent.setData(Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/DCIM/Camera/PANO_20131209_130755.jpg"));
startActivity(intent);

Thanks in advance,


回答1:


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<PanoramaResult>() {
        @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.



来源:https://stackoverflow.com/questions/20953092/how-to-set-photosphere-mode-when-open-panorama-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!