1
定製等距離長方圓柱像我有這樣一個等距離長方圓柱投影圖像:使用PanoramaApi從Assets文件夾
我在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();
}
}