Permission Dialogs for Users in Java

Tango works by using visual cues from the device's cameras. We want users to understand when and why the cameras are being used, so you must ask users for permission prior to using area learning or displaying the camera preview.

TangoService will not work without the user's permission in these cases.

How to request user permission

Android Camera permission

Applications that intend to use depth perception or show the camera preview must request the Android Camera permission in their manifest to get access to the camera feed through the Tango API.

ADF permissions

ADF Load/Save intent

To request load/save permission, call the following Android permission intent. If the user hasn't given permission, this intent will show a popup asking for the permission. If you call this intend and the user already gave permission, no popup will be shown.

startActivityForResult(
    Tango.getRequestPermissionIntent(Tango.PERMISSIONTYPE_ADF_LOAD_SAVE),
    Tango.TANGO_INTENT_ACTIVITYCODE);

ADF Import intent

Use Tango.importAreaDescriptionFile() to import an ADF from the filesystem. A permission screen will appear each time you call the method.

You can also create the intent yourself:

private static final String INTENT_CLASSPACKAGE = "com.projecttango.tango";
private static final String INTENT_IMPORTEXPORT_CLASSNAME = "com.google.atap.tango.RequestImportExportActivity";

// startActivityForResult requires a code number.
private static final String EXTRA_KEY_SOURCEFILE = "SOURCE_FILE";

Intent importIntent = new Intent();
importIntent.setClassName(INTENT_CLASSPACKAGE, INTENT_IMPORTEXPORT_CLASSNAME);
importIntent.putExtra(EXTRA_KEY_SOURCEFILE, filepath);
thisActivity.startActivityForResult(importIntent, Tango.TANGO_INTENT_ACTIVITYCODE);

ADF Export intent

Use Tango.exportAreaDescriptionFile() to export an ADF to the filesystem. A permission screen will appear for each intent you send.

You can also create the intent yourself:

private static final String INTENT_CLASSPACKAGE = "com.projecttango.tango";
private static final String INTENT_IMPORTEXPORT_CLASSNAME = "com.google.atap.tango.RequestImportExportActivity";

// startActivityForResult requires a code number.
private static final String EXTRA_KEY_SOURCEUUID = "SOURCE_UUID";
private static final String EXTRA_KEY_DESTINATIONFILE = "DESTINATION_FILE";

Intent exportIntent = new Intent();
exportIntent.setClassName(INTENT_CLASSPACKAGE, INTENT_IMPORTEXPORT_CLASSNAME);
exportIntent.putExtra(EXTRA_KEY_SOURCEUUID, mUUIDList[info.position]);
exportIntent.putExtra(EXTRA_KEY_DESTINATIONFILE, mAppSpaceADFFolder);
thisActivity.startActivityForResult(exportIntent, Tango.TANGO_INTENT_ACTIVITYCODE);

API exceptions

If you try to call a method that requires a permission that has not been granted, the Java API throws a SecurityException with a detailed message corresponding to the permission that failed.

API calls that require permission

The following calls in the Java API require the user's permission.

API calls that require Tango.PERMISSIONTYPE_ADF_LOAD_SAVE

  • Tango.saveAreaDescription
  • Tango.deleteAreaDescription
  • Tango.listAreaDescriptions
  • Tango.loadAreaDescriptionMetaData
  • Tango.saveAreaDescriptionMetadata

API calls that require Android Camera permissions

  • Tango.getCameraIntrinsics
  • onXYZijAvailable callback of Tango.OnTangoUpdateListener
  • onFrameAvailable callback of Tango.OnTangoUpdateListener
  • Tango.connectTextureId
  • Tango.disconnectCamera

Enviar comentarios sobre…