全景Api意图null

时间:2016-12-26 15:55:06

标签: android 360-panorama-viewer

我正在尝试使用Panorama API查看全景图像但是当我尝试尝试启动图像时,PanoramaResult.getViewerIntent()方法返回null并且不应该为null。

PanoramaResult的结果是:

Status{statusCode=SUCCESS, resolution=null}

代码:

 private GoogleApiClient gacClient;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    gacClient = new GoogleApiClient.Builder(this, this, this)
            .addApi(Panorama.API)
            .build();
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(intent,CAPTURE_TERRAT_GALLERY_ACTIVITY_REQUEST_CODE);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    int columnIndex;
    Cursor cursor;
    String imagenADecodificar;

    if (requestCode==CAPTURE_TERRAT_GALLERY_ACTIVITY_REQUEST_CODE && resultCode==RESULT_OK && data!=null){
        fileUri = data.getData();
        String [] rutaColumna= {MediaStore.Images.Media.DATA};
        cursor= getContentResolver().query(fileUri,rutaColumna,null,null,null);
        cursor.moveToFirst();
        columnIndex = cursor.getColumnIndex(rutaColumna[0]);
        imagenADecodificar = cursor.getString(columnIndex);
        fileUri = Uri.parse(imagenADecodificar);
        cursor.close();
    }
}

@Override
public void onStart() {
    super.onStart();
    gacClient.connect();
}

@Override
public void onConnected(Bundle connectionHint) {
    Panorama.PanoramaApi.loadPanoramaInfo(gacClient, fileUri).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
                    }
                }
            });

}

@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();
}

}

2 个答案:

答案 0 :(得分:0)

  

<强>返回   如果图像是全景图,则不为空,并且在启动时将启动查看器。如果图像不是全景图,则该图像将为空。

Documentation

你确定你的图像是有效的全景图吗?

答案 1 :(得分:0)

我使用Nexus 5的相机模式全景拍摄的图像