简体   繁体   中英

Android: Bound Service or Singleton

我正在创建一个离线聊天机器人,并想知道使用Bound Service或Singleton作为解析/响应引擎是否是一个好习惯?

Service and Singleton are two different concepts.

We use Singleton is a pattern to initiate and use one instance only.

Service is a component for longer-running operation that runs in background.

Bound Service :

A bound service is the server in a client-server interface. Service that binds several applications or Activities.

Im creating an offline chatbot ..

If you think to develop Program talks to other application, bear in mind that on Android, one process cannot normally access the memory of another process. I offer you to use AIDL (Android Interface Definition Language)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM