This class is the main entry point of the library, this is the first class that you should be using.

Create a new client

The easiest way is

Kotlogram.getDefaultClient(application, new TelegramApiStorageImpl());

Here, the TelegramApiStorageImpl is not detailed, but your implementation should persist info in persistent memory (DB, file, ...).

Or, you may also use this method overloads

  • preferredDataCenter: if you want to try connecting to a specific datacenter first (for example, if you know your closest dc). It could save some exchange (a few ms...) while creating the first client.
  • updateCallback: callback called when an update is received from Telegram (new message, new group created, new friend joined Telegram, ...).

Get a specific DataCenter

You can use getDcById method or getDcId methods :)

Get API layer at runtime

int layer = Kotlogram.API_LAYER;

Clean up

Once you're done, and you closed all your clients, to let your process finish, call:


Did this page help you?