希望下面的以下幫助:
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();
}
}
下面是庫的鏈接,例如使用PhotoSphere
而不是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);
光球使用陀螺儀和加速度計沒有,但是我相信你可以使用第二個解決方案,並添加自己的加速功能。
'「file://」+「/ sdcard' - 這是不好的做法,參見'環境'類 –
是的,我知道,我只是把它作爲測試。 – benoitm76
提供了滾動你的圖像的按鈕的代碼,請 – ProllyGeek