目录

1. Invoking Mode

Panoramas can be presented inside or outside an app.

2. Panorama Presented Outside an App

To present a panorama outside an app, your app needs to obtain the intent for redirecting to the panorama display activity from HUAWEI Panorama Kit and pass the intent to startActivity to start the redirection. The procedure is as follows:

Pass the panorama URI to obtain the intent for redirecting to the panorama display activity and further complete the redirection. 

Call either of the following APIs:

PendingResult<ImageInfoResult> loadImageInfo(Context context, Uri uri);

PendingResult<ImageInfoResult> loadImageInfoWithPermission(Context context, Uri uri);

ParameterDescription
contextAPP context. 

To actively trigger an upgrade, pass an Activity object.

uri

URI of the panorama to be loaded.

URIs starting with file, content, or android.resource are supported.

Note:

For Android 10.0 and later versions, media files in external storage space cannot be directly accessed by path due to app sandboxing. You can obtain the media file URI through ContentResolver

The intent can be called synchronously or asynchronously. The sample code is as follows:

  1. new Thread(new Runnable() {
  2.    @Override
  3.    public void run() {
  4.        PanoramaInterface.ImageInfoResult panoramaResult = Panorama.getInstance().loadImageInfo(MainActivity.this, uri).await();
  5.        if (panoramaResult == null) {
  6.            Log.e(LOG_TAG, "ImageInfoResult is null");
  7.            return;
  8.        }
  9.        if (panoramaResult.getStatus().isSuccess()) {
  10.            Intent intent = panoramaResult.getImageDisplayIntent();
  11.            if (intent != null) {
  12.                 startActivity(intent);
  13.            }
  14.        } else {
  15.             Log.e(LOG_TAG, "error: " + panoramaResult);
  16.        }
  17.    }
  18. }).start();
Note:
If the synchronization API is called in the main thread, an Application Not Responding (ANR) error will be triggered.
  1. Panorama.getInstance().loadImageInfo(this, uri).setResultCallback(
  2.    new ResultCallback<PanoramaInterface.ImageInfoResult>() {
  3.        @Override
  4.        public void onResult(PanoramaInterface.ImageInfoResult panoramaResult) {
  5.            if (panoramaResult == null) {
  6.                Log.e(LOG_TAG, "ImageInfoResult is null");
  7.                return;
  8.            }
  9.            if (panoramaResult.getStatus().isSuccess()) {
  10.                Intent intent = panoramaResult.getImageDisplayIntent();
  11.                if (intent != null) {
  12.                    startActivity(intent);
  13.                }
  14.            } else {
  15.                Log.e(LOG_TAG, "error: " + panoramaResult);
  16.            }
  17.        }
  18.    });
Note:

3. Panorama Presented Outside an App Without Metadata

Some panoramas do not have metadata. They can be presented only after their types are specified. The required APIs are as follows:

PendingResult<ImageInfoResult> loadImageInfo(Context context, Uri uri, int type);

PendingResult<ImageInfoResult> loadImageInfoWithPermission(Context context, Uri uri, int type);

ParameterDescription
contextAPP context.

To actively trigger an upgrade, pass an Activity object.

uri

URI of the panorama to be loaded. 

URIs starting with file, content, or android.resource are supported.

typeImage type. Currently, spherical and cylindrical panoramas are supported.

The method used by the preceding API to obtain the redirection intent is the same as that of the PanoramaInterface.loadImageInfo API. The sample code is as follows:

  1. new Thread(new Runnable() {
  2.    @Override
  3.    public void run() {
  4.        PanoramaInterface.ImageInfoResult panoramaResult = Panorama.getInstance().loadImageInfo(MainActivity.this, uri, PanoramaInterface.IMAGE_TYPE_SPHERICAL).await();
  5.        if (panoramaResult == null) {
  6.            Log.e(LOG_TAG, "ImageInfoResult is null");
  7.            return;
  8.        }
  9.        if (panoramaResult.getStatus().isSuccess()) {
  10.            Intent intent = panoramaResult.getImageDisplayIntent();
  11.            if (intent != null) {
  12.                startActivity(intent);
  13.            }
  14.        } else {
  15.            Log.e(LOG_TAG, "error: " + panoramaResult);
  16.        }
  17.    }
  18. }).start();
  1. Panorama.getInstance().loadImageInfo(this, uri,  PanoramaInterface.IMAGE_TYPE_SPHERICAL).setResultCallback(
  2.    new ResultCallback<PanoramaInterface.ImageInfoResult>() {
  3.        @Override
  4.        public void onResult(PanoramaInterface.ImageInfoResult panoramaResult) {
  5.            if (panoramaResult == null) {
  6.                Log.e(LOG_TAG, "ImageInfoResult is null");
  7.                return;
  8.            }
  9.            if (panoramaResult.getStatus().isSuccess()) {
  10.                Intent intent = panoramaResult.getImageDisplayIntent();
  11.                if (intent != null) {
  12.                    startActivity(intent);
  13.                }
  14.            } else {
  15.                Log.e(LOG_TAG, "error: " + panoramaResult);
  16.            }
  17.        }
  18.    });
Note: