Most users using
CSEntry on Android will be content working within the confines of the CSPro ecosystem. However, some users may want to share data between Android applications. To facilitate this, CSPro supports several ways to interact with other Android applications.
Using the
SystemApp object and the
SystemApp.exec function, you can open other applications from within a CSPro application. Due to
limitations imposed by Google that restrict what applications can be opened, using a
deep link to open the other application is the best approach. For example:
// get driving directions from the White House to the U.S. Census Bureau using an Organic Maps deep link
SystemApp organic_maps;
organic_maps.exec(maketext("om://route?sll=%v,%v&saddr=%s&dll=%v,%v&daddr=%s&type=vehicle",
38.897778, -77.036389, encode(PercentEncoding, "White House"),
38.84839, -76.931098, encode(PercentEncoding, "U.S. Census Bureau")));
Android's
scoped storage prevents applications from accessing potentially sensitive data created by other applications. Other applications will not be able to access data in the
gov.census.cspro.csentry directory. If you would like to share files with other applications, there are a few options:
Copy a file to the Downloads directory: All applications are able to write to the Downloads directory. To copy a file to that directory, you can access the directory's path using the
pathname or
Path.concat functions. For example:
CS.File.copy(source := "file-in-application-directory.jpg",
destination := Path.concat(Downloads, "file-in-downloads-directory.jpg"));
Copy a system document: Some files, especially
media files are accessible to CSEntry. These files cannot be opened directly, but can be copied to the
gov.census.cspro.csentry directory and manipulated from that location. These files must be copied using a
sharable URI. For example, this code allows the user to select a system document and then copies it to the application's directory:
Make a file available to other applications: If you are launching another application using
SystemApp.exec, or
calling into CSEntry using the Action Invoker, you may want to create a reference to a file in the
gov.census.cspro.csentry directory and make it available to the other application. You can do this by creating a
sharable URI and passing this URI to the other application. The other application can then use this URI to access the file. For example: