Skip to content

ASAP (Asynchronous Semantic Ad-hoc) intigration for mobile Bluetooth Messenger

Notifications You must be signed in to change notification settings

MathisHTW/Bluetooth_Messenger

Repository files navigation

Bluetooth_Messenger

How to ASAP integration?

Your need min. 3 Classes ASAPApplication, ASAPInit and ASAPRootAcitivity

Example:

ASAPApplication


public class BTApplication extends net.sharksystem.asap.android.apps.ASAPApplication {
    public static final String ASAP_Messenger = "ASAP_MESSENGER";
    private CharSequence id;
    static BTApplication instance;

    protected BTApplication(Collection<CharSequence> supportedFormats, Activity initialActivity) {
        super(supportedFormats, initialActivity);
        this.id = ASAP.createUniqueID();
    }

    /**
     * ASAP access
     * Source: https://github.com/SharedKnowledge/ASAPAndroid/blob/7cec8ba190acd859d848e07a584679022b9b8993/app/src/main/java/net/sharksystem/asap/android/example/ASAPExampleApplication.java#L11
     *
     * @param initialActivity
     * @return
     */
    public static BTApplication applicationInstance(Activity initialActivity) {
        if(BTApplication.instance == null) {
            Collection<CharSequence> formats = new ArrayList<>();
            formats.add(ASAP_Messenger);

            // create
            BTApplication.instance = new BTApplication(formats, initialActivity);

            // there could be some other steps. Setting up sub components. But there are non here.

            // launch
            BTApplication.instance.startASAPApplication();
        } // else - already initialized - nothing happens.

        return BTApplication.instance;
    }

    public static BTApplication getInstance() {
        return instance;
    }

    public CharSequence getOwnerID() {
        return this.id;
    }

}

ASAPInit


public class BTInit extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        BTApplication.applicationInstance(this);

        // launch real first activity
        this.finish();
        Intent intent = new Intent(this, Start.class);
        this.startActivity(intent);
    }
}

ASAPRootAcitivity


public class BTRootActivity extends ASAPActivity {
    public BTRootActivity() {
        super(BTApplication.getInstance());
    }
}

Last but not least let the "ASAPRootAcitivity" inherit the class where you want to start ASAP

Example:

public class Start extends BTRootActivity {

    private AppController appController = AppController.instance;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        final Read read = new Read();
        read.localStorage(getApplication());

        if (Storage.getInstance().getChannelList().size() == 0) {
            final Create create = new Create();
            create.createChannel("Public");
        }

        appController.onActivityCreated(this, savedInstanceState);
    }
    ...

About

ASAP (Asynchronous Semantic Ad-hoc) intigration for mobile Bluetooth Messenger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages