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,
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With