Hi,
i'm playing around with the BB JDE 5.0.0 API and i'm trying to create an app that reacts when a BBM message is received.
I have looked at the example (TicTacToe) app which should explain this, but this app actually connects with another user first to initiate the interaction.
I just want to react on an incoming BBM message without knowing who sent it.
The API-docs do not make it very clear to me so i hope there's someone out here that can.
Here's a sample of my code which doesn't work:
Code:
// intentionally omitted imports to shorten post
public class BBMReact extends UiApplication
{
public static void main(String[] args)
{
// don't know if this is necessary, except when using a screen
BBMReact bbmReact = new BBMReact();
bbmReact.enterEventDispatcher();
ApplicationDescriptor adBBMReact = ApplicationDescriptor.currentApplicationDescriptor();
BlackBerryMessenger bbm = BlackBerryMessenger.getInstance();
if (bbm != null)
{
bbm.addSessionRequestListener(new BBMReactRequestListener(), adBBMReact);
}
public BBMReact ()
{
// some constructor code (maybe a pushscreen or something)
}
}
private class BBMReactRequestListener implements SessionRequestListener
{
public void sessionRequestAccepted( Session session )
{
session.addListener(new BBMReactSessionListener(), ApplicationDescriptor.currentApplicationDescriptor());
}
}
private class BBMReactSessionListener implements SessionListener
{
public BBMReactSessionListener()
{
// TODO Auto-generated constructor stub
}
public void messageDelivered(Session session, Message message)
{
// TODO Auto-generated method stub
}
public void messageQueuedForSend(Session session, Message message)
{
// TODO Auto-generated method stub
}
public void messageReceived(Session session, Message message)
{
// This is where the reaction should take place
Dialog.alert("You've got a BBM message!");
}
public void messageSent(Session session, Message message)
{
// TODO Auto-generated method stub
}
public void sessionClosed(Session session)
{
// TODO Auto-generated method stub
}
}
Where or what am i doing wrong? Plz, help me understand the BBM API