Child pages
  • Android application
Skip to end of metadata
Go to start of metadata

Download it from here.

Get a short introduction to the Android platform and Apstrata Android SDK for the demo application here.

Android application: implementation tips

1. API calls to make from the Android application (using the Apstrata Android client SDK)

Note: most of the methods exposed by the Android client SDK to invoke Apstrata's APIs gather the required parameters into an instance of a List of NamedValuePair instances). In the below, we use the following convention to represent the content of this list: 
{ "key1" : "value1", "key2" : "value2" } : a list of namedvalue pairs containing two key/value pairs
{ }:  stands for an empty NSDictionary.

For more details on the Android client SDK click here

1.a. To retrieve the list of available concerts

Use one of the following methods of the Android client SDK:
callAPIJson (String methodName, List<NameValuePair> params, Map<String, List<File>> files) throws Exception 

(returns the result in JSON format)

callAPI (String methodName, List<NameValuePair> params, Map<String, List<File>> files) throws Exception
(returns the result in XML format by default, unless the format is specified),

with the following parameters:
  • methodName: "Query"
  • params: { "apsdb.query" : "apsdb.schema = \"concert\" ", "apsdb.queryFields" : "title, ticketPriceLL, picture, description, date, apsdb.documentKey" }
  • files: { }
Note:  this is the minimum required to query for documents. If we assume that the query returns a large amount of documents, then we should add the following to the params dictionary: [..., ("apsdb.count", "true"), ("apsdb.resultsPerPage", "some_number"), ("apsdb.pageNumber", "the_page_number")]

1.b. In order to retrieve the URL of the picture / or download the picture

The above query returns the name of the picture file in the "picture" field, therefore:

use the following method of the Android client SDK to retrieve the URL of the picture file: 

getSignedRequestUrl(String action, List<NameValuePair> parameters, Map<String, List<File>> files) throws Exception;

returns a String representing the full URL to the file

or use the method hereafter to actually download the file

callAPIFile(String methodName, List<NameValuePair> params, String path) throws Exception;

returns an instance of java.io.File

last, you can use the below method to retrieve a stream to the file

callAPIStream(String methodName, List<NameValuePair> params, Map<String, List<File>> files, HttpClient httpClient) throws Exception
Note: In the case of the workshop application, all documents have a schema and the name of the field used to attach files (images) is "picture".

1.c. To retrieve the picture gallery of a given concert

Use callAPIJson (returns the result in JSON format) or callAPI of the Android SDK (returns the result in XML or as specified in the sent parameters, see documentation), with the following parameters:
  • methodName: "Query"
  • params: { "apsdb.query" : "concert= \"the_key_of_the_concert_document\" ", "apsdb.queryFields" : "picture" }
  • files: { }
Note: the query returns the names of the image files. You then need to use "getFileUrl" to obtain a link to each image, as many times as there are images.

1.d. To upload an image to the gallery

Use callAPI of the Android SDK (returns the result in XMLr as specified in the sent parameters, see documentation), with the following parameters:

  • methodName: "SaveDocument"
  • params: { "apsdb.schema" : "concert_image", "concert" : "the_key_of_the_concert_document", "title" : "the_title_of_the_img",  "description" : "some_description", "tags" : "tag1,tag2,etc" }
  • files: { a dictionary of key/NamedFileData instances, see example of code below }

 

 

  • No labels