The Android Client

The Android client objects (Gateway, Wallet, Passport, Monitor, etc) run within the Android Activity as instance variables. The client objects are created and destroyed with the Android Activity. Each Activity that interfaces with Keychain should use the client objects as instance variables.

The Android client uses an embedded database that is separate than the application’s SQLite database. The Keychain database is created in the APPDATA directory with a name MODULE-keychain.db.

As the Gateway and Wallet classes are lightweight in that they do not perform network calls. These classes only access the Keychain database. As such, they are generally safe to call on the UI thread.

Passport, on the other hand, performs blockchain operations with synchronous network calls. As such, Passport methods generally should be called only on a thread that is separate than the UI thread using, for example, AsyncTask.

Likewise, the Monitor object performs (semi) blocking, synchronous pub/sub network operations to receive updates from Query servers. Monitor automatically creates a thread for you when onStart() is called. Monitor should be registered as a Activity Lifecycle Observer in the Activity onCreate() method. This will cause the Monitor to start, resume, pause, and stop in synch with the Activity lifecycle transitions automatically.