Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set photosphere mode when open panorama Android

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,

like image 342
benoitm76 Avatar asked Jan 06 '14 15:01

benoitm76


People also ask

How do you click a picture sphere?

Create a photo sphere with your Android device: Open the Google Camera app on your device. Swipe to the right and touch Photo Sphere. Hold your device vertically, close to your body. Adjust the camera angle so the blue dot is centered inside the circle.


1 Answers

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.

like image 95
Kevin Crain Avatar answered Oct 21 '22 21:10

Kevin Crain