Entwicklungshandbuch
Local Navigation
- Überblick über das BlackBerry Messenger SDK
- BlackBerry Messenger-Versionsabhängigkeiten
- Wichtige Klassen der BlackBerry Messenger-Plattform
- Registrieren Ihrer Anwendung bei der BlackBerry Messenger-Plattform
- Interaktion mit Kontakten
- Freigeben von Inhalt für BlackBerry Messenger-Kontakte
- Arbeiten mit dem Profil und Profilfeld des Benutzers
- Definieren von Dienst-Listenern
- Verwalten der BlackBerry Messenger-Einstellungen Ihrer Anwendung
- Fehlerbehebung
- Rückmeldung
- Rechtliche Hinweise
Produktunterlagen
>
Entwicklerdokumentation
>
BlackBerry Messenger Social Platform SDK
>
Entwicklungshandbuch
BlackBerry Messenger SDK - 1.3
Definieren eines Kanallisteners
Im folgenden Codebeispiel wird davon ausgegangen, dass Sie diese Klasse als Teil einer Anwendung erstellen, die einen Kanallistener benötigt.
- Importieren Sie die erforderlichen Klassen und Schnittstellen.
import net.rim.blackberry.api.bbm.platform.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*;
- Erstellen Sie das Framework für den Kanallistener, und definieren Sie die Signatur jeder Rückrufmethode. Das folgende Codebeispiel zeigt eine Nachricht mit der Information an, welches Ereignis aufgetreten ist.
class MyChannelListener extends BBMPlatformChannelListener { public void invitationAccepted(BBMPlatformConnection connection, BBMPlatformContact contact) { Dialog.inform(contact.getDisplayName() + " has accepted your invitation."); } public void invitationDeclined(BBMPlatformConnection connection, String contactDisplayName) { Dialog.inform(contactDisplayName + " has declined your invitation."); } public void invitationFailed(BBMPlatformConnection connection, String inviteeName, int reasonCode) { Dialog.inform(inviteeName + " has failed to receive your invitation. Error: " + reasonCode); } public void contactLeft(BBMPlatformConnection connection, BBMPlatformContact contact) { Dialog.inform(contact.getDisplayName() + " has left the application."); } //NOTE: The message parameter is received as a data array. This method converts message to a String before displaying. public void dataReceived(BBMPlatformConnection connection, BBMPlatformContact fromContact, BBMPlatformData message) { Dialog.inform(fromContact.getDisplayName() + ": " + new String(message.getData())); } //NOTE: param is a custom parameter defined by the application and passed in from the sender of the invitation public void invitationReceived(BBMPlatformConnection connection, BBMPlatformContact contact, String param) { Dialog.inform(contact.getDisplayName() + ": " + param); } public void invitationsSent(BBMPlatformConnection connection, int count) { Dialog.inform("I've sent " + count + " invitations."); } public void joinFailed(BBMPlatformConnection connection, BBMPlatformContact inviter, int reasonCode) { Dialog.inform("The user has failed to join the session. Error: " + reasonCode); } }
Nächstes Thema: Definieren eines Nachrichtendienst-Listeners
Vorheriges Thema: Definieren von Dienst-Listenern
Waren diese Informationen hilfreich? Senden Sie uns Ihren Kommentar.