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
Panoramas can be presented inside or outside an app.
Panorama presented outside an app: The app obtains an intent by calling the API of the HMS Core Panorama SDK and redirects to Activity in HUAWEI Panorama Kit to present panoramas. In this mode, HUAWEI Panorama Kit uses the loadImageInfo or loadImageInfoWithPermission API to create a window outside the app.
Panorama presented inside an app: The app presents panoramas in its own process by calling getLocalInstance and PanoramaLocalInterface of the HMS Core Panorama SDK. In this mode, HUAWEI Panorama Kit returns a panoramic layer, and the app determines the position to display the layer and whether to superimpose other information (such as ads) on the layer.
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);
| Parameter | Description |
|---|---|
| context | APP 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. |
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:
- new Thread(new Runnable() {
- @Override
- public void run() {
- PanoramaInterface.ImageInfoResult panoramaResult = Panorama.getInstance().loadImageInfo(MainActivity.this, uri).await();
- if (panoramaResult == null) {
- Log.e(LOG_TAG, "ImageInfoResult is null");
- return;
- }
- if (panoramaResult.getStatus().isSuccess()) {
- Intent intent = panoramaResult.getImageDisplayIntent();
- if (intent != null) {
- startActivity(intent);
- }
- } else {
- Log.e(LOG_TAG, "error: " + panoramaResult);
- }
- }
- }).start();
- Panorama.getInstance().loadImageInfo(this, uri).setResultCallback(
- new ResultCallback<PanoramaInterface.ImageInfoResult>() {
- @Override
- public void onResult(PanoramaInterface.ImageInfoResult panoramaResult) {
- if (panoramaResult == null) {
- Log.e(LOG_TAG, "ImageInfoResult is null");
- return;
- }
- if (panoramaResult.getStatus().isSuccess()) {
- Intent intent = panoramaResult.getImageDisplayIntent();
- if (intent != null) {
- startActivity(intent);
- }
- } else {
- Log.e(LOG_TAG, "error: " + panoramaResult);
- }
- }
- });
Currently, only URIs starting with file, content, or android.resource are supported.
The loadImageInfoWithPermission API is the same as the loadImageInfo API except that the intent it calls contains FLAG_GRANT_READ_URI_PERMISSION, an authorization flag for HUAWEI Panorama Kit to temporarily access the image URI.
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);
| Parameter | Description |
|---|---|
| context | APP 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. |
| type | Image 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:
- new Thread(new Runnable() {
- @Override
- public void run() {
- PanoramaInterface.ImageInfoResult panoramaResult = Panorama.getInstance().loadImageInfo(MainActivity.this, uri, PanoramaInterface.IMAGE_TYPE_SPHERICAL).await();
- if (panoramaResult == null) {
- Log.e(LOG_TAG, "ImageInfoResult is null");
- return;
- }
- if (panoramaResult.getStatus().isSuccess()) {
- Intent intent = panoramaResult.getImageDisplayIntent();
- if (intent != null) {
- startActivity(intent);
- }
- } else {
- Log.e(LOG_TAG, "error: " + panoramaResult);
- }
- }
- }).start();
- Panorama.getInstance().loadImageInfo(this, uri, PanoramaInterface.IMAGE_TYPE_SPHERICAL).setResultCallback(
- new ResultCallback<PanoramaInterface.ImageInfoResult>() {
- @Override
- public void onResult(PanoramaInterface.ImageInfoResult panoramaResult) {
- if (panoramaResult == null) {
- Log.e(LOG_TAG, "ImageInfoResult is null");
- return;
- }
- if (panoramaResult.getStatus().isSuccess()) {
- Intent intent = panoramaResult.getImageDisplayIntent();
- if (intent != null) {
- startActivity(intent);
- }
- } else {
- Log.e(LOG_TAG, "error: " + panoramaResult);
- }
- }
- });
Currently, only URIs starting with file, content, or android.resource are supported.
Currently, spherical and cylindrical panoramas are supported
The loadImageInfoWithPermission API is the same as the loadImageInfo API except that the intent it calls contains FLAG_GRANT_READ_URI_PERMISSION, an authorization flag for HUAWEI Panorama Kit to temporarily access the image URI.