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.
"file://" + "/sdcard
- this is bad approach. SeeEnvironment
class – PantinPanoramaViewActivity
only looks at the dataUri
set to the incomingIntent
, orEXTRA_STREAM
if the former isnull
. There is no 'extra' to supply the mode. – Swanger