我有一个像这样的equirectangular图像:
我在AssetsFolder中有图像,因此我将此uri传递给Panorama.PanoramaApi.loadPanoramaInfo方法:
Uri uri = Uri.parse("file:///android_asset/panorama/equi_1.jpg");
不知何故,如果我检查result.getViewerIntent,我得到null作为返回值。
我的直觉说这可能与这个图像不是用谷歌相机应用程序创建的事实有关,因此缺少一些元标记,但我不确定。
我的PanoramaActivity的完整代码:
public class PanoramaActivity extends Activity implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
public static final String PANORAMA_URI = "panorama_uri";
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) {
Intent intent = getIntent();
if (intent != null) {
String fileUri = intent.getStringExtra(PANORAMA_URI);
if (fileUri != null && !fileUri.isEmpty()) {
Uri uri = Uri.parse("file:///android_asset/panorama" + fileUri);
Panorama.PanoramaApi.loadPanoramaInfo(gacClient, uri).setResultCallback(
new ResultCallback<PanoramaApi.PanoramaResult>() {
@Override
public void onResult(PanoramaApi.PanoramaResult result) {
Intent i;
if (result.getStatus().isSuccess() && (i = result.getViewerIntent()) != null) {
startActivity(i);
} else {
// Handle unsuccessful result
}
}
});
} else {
finish();
}
} else {
finish();
}
}
@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();
}
}
答案 0 :(得分:1)