Content Providers
Build Android apps and connected devices that integrate with Beeper using standard Android ContentProvider APIs. Content providers encapsulate data and provide mechanisms for defining data security, serving as the standard interface between processes.
What You Can Build
Section titled “What You Can Build”- Universal Search - Search across all chats and messages
- Widgets & Dashboards - Display chat summaries and unread counts
- Automation - Send messages and react to changes
- Wearables - Integrate with watches and IoT devices
Key Features
Section titled “Key Features”- Authority:
com.beeper.api
- Permissions: Runtime (request at first use)
- Data Access: Chats, messages, contacts
- Operations: Query, insert, observe changes
- Protocol Support: WhatsApp, Telegram, Signal, and more
Quick Start
Section titled “Quick Start”-
Add permissions to your manifest
AndroidManifest.xml <uses-permission android:name="com.beeper.android.permission.READ_PERMISSION" /><uses-permission android:name="com.beeper.android.permission.SEND_PERMISSION" />// Request at runtime (e.g., in an Activity or Fragment)val requestPermissions = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { results ->val hasRead = results["com.beeper.android.permission.READ_PERMISSION"] == trueval hasSend = results["com.beeper.android.permission.SEND_PERMISSION"] == true// Handle granted/denied states}requestPermissions.launch(arrayOf("com.beeper.android.permission.READ_PERMISSION","com.beeper.android.permission.SEND_PERMISSION")) -
Query recent chats
import androidx.core.net.toUrival uri = "content://com.beeper.api/chats?limit=50".toUri()contentResolver.query(uri, null, null, null, null)?.use { cursor ->val titleIdx = cursor.getColumnIndexOrThrow("title")val previewIdx = cursor.getColumnIndexOrThrow("messagePreview")val unreadIdx = cursor.getColumnIndexOrThrow("unreadCount")while (cursor.moveToNext()) {val title = cursor.getString(titleIdx)val preview = cursor.getString(previewIdx)val unread = cursor.getInt(unreadIdx)// Display chat info in your UI}} -
Send a message
import android.net.Uriimport androidx.core.net.toUrival message = "Hello from my app!"val roomId = "!room:server.com"val result = contentResolver.insert(("content://com.beeper.api/messages?" +"roomId=$roomId&text=${Uri.encode(message)}").toUri(),null)result?.let {val messageId = it.getQueryParameter("messageId")// Message sent successfully} -
Observe changes
import android.os.Handlerimport android.os.Looperimport android.database.ContentObserverimport androidx.core.net.toUricontentResolver.registerContentObserver("content://com.beeper.api/chats".toUri(),true,object : ContentObserver(Handler(Looper.getMainLooper())) {override fun onChange(selfChange: Boolean) {// Re-query and refresh your UI}})
Common Use Cases
Section titled “Common Use Cases”// Get total unread count across all chatsval uri = "content://com.beeper.api/chats/count?isUnread=1".toUri()val cursor = contentResolver.query(uri, null, null, null, null)val unreadTotal = cursor?.use { if (it.moveToFirst()) { it.getInt(it.getColumnIndexOrThrow("count")) } else 0} ?: 0
// Search with surrounding contextval searchTerm = "meeting"val uri = ("content://com.beeper.api/messages?" + "query=${Uri.encode(searchTerm)}" + "&contextBefore=2&contextAfter=2").toUri()
contentResolver.query(uri, null, null, null, null)?.use { cursor -> val textIdx = cursor.getColumnIndexOrThrow("text_content") val matchIdx = cursor.getColumnIndexOrThrow("is_search_match")
while (cursor.moveToNext()) { val text = cursor.getString(textIdx) val isMatch = cursor.getInt(matchIdx) == 1 // Highlight matches in UI }}
// Get WhatsApp chats onlyval uri = "content://com.beeper.api/chats?protocol=whatsapp".toUri()contentResolver.query(uri, null, null, null, null)?.use { cursor -> // Process WhatsApp-specific chats}
Performance Tips
Section titled “Performance Tips”Supported Protocols
Section titled “Supported Protocols”Protocol | Identifier | Features |
---|---|---|
whatsapp | Full | |
Telegram | telegram | Full |
Signal | signal | Full |
Matrix/Beeper | beeper , matrix | Full |
Discord | discord | Full |
Slack | slack | Full |
Google Messages | gmessages | Full |
Others | Various | Query |
Learn More
Section titled “Learn More”- API Reference → - Complete API documentation for all endpoints
- Integration Guide → - Permissions, notifications, and troubleshooting
- Android Docs → - Official ContentProvider documentation