Skip to content

Implement an Android ASAP application

Thomas Schwotzer edited this page Jan 18, 2021 · 16 revisions

Start with Java

We strongly suggest to implement you application logic as free as possible from Android. In any case, read the Implement an ASAP application before you go on with Android. It not long. Hava look.

This documentation assumes that your ASAP related code is implemented and tested on Java and you plan to run use it on Android.

Concept of this lib: service and application side

This library has two major components: There is a service in which an ASAPPeer runs. The service tries to (re-)created ad-hoc connections whenever possible and - of course - allowed from you. ASAP sessions are performed in that service. You do not have to care about this service at all. We call it service side.

You implement an Android application. That is what we call the application side. Both side communicate with message (application to service side) and broadcasts (service to application side). You will get in contact with any of those details but in one occasions: When you setup your application. Afterwards, you will not be bothered with any details of ASAP or layer 2 protocols. Your Java code will work without any change if you used the interfaces explained in Implement an ASAP application.

Setup

You have already learned about the ASAPPeer interface and its usage. We now explain how to setup the system and how to get an object that implements ASAPPeer.

There is one ASAP peer running in the service. This peer requires two parameters to be constructed: A list of supported formats and a name. A name can be generated but the parameters must come from you. The format parameter is discussed here.

A unique name can be produced by calling ASAP.createUniqueID().

The setup process must be performed in two steps: 1. All parameters are defined and given to the library. 2. The library / the peer is started.

There are two classes on application side which handle communication with service side: ASAPActivity and ASAPAndroidPeer. You will deal with the later only during setup. You need to derive any of your activity from ASAPActivity if you want to use ASAP, though.

There seams to be a chicken-egg-problem: An activity is required to setup the ASAPAndroidPeer. Each ASAPActivity (and derived classes) can only be created after an ASAPAndroidPeer has successfully been set up. The solution is very simple: There must be an initial activity that does not derive from ASAPActivity which sets up the systems. Afterwards it launches another activity.

Follow this rule of thumb: Derive any of your activities from ASAPActivity but this initial one. Here is an example of such an initial activity.

Clone this wiki locally