BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   UserProfile - Blackberry Messenger SDK (http://www.blackberryforums.com/developer-forum/259282-userprofile-blackberry-messenger-sdk.html)

clowicek 05-01-2012 02:20 AM

UserProfile - Blackberry Messenger SDK
 
Hello All,
for first time... i`m sorry for my english.
Now to my problem. I programmed an application that uses information from BBM ... The application has a splash screen and when I am start application as it is properly registered in my BBM where it and i see it. Nevertheless, he ends up splash screen so I do not have access to information from BBM. Rather, I am unable to initialize BBMPlatformContext in new screen so that I could use userprofile USERPROFILE = platformContext.getUserProfile (), etc.
probably doing something wrong but I'm not in a state to find out what.

this is code which started if application run (BBM is already registered)
Code:

import net.rim.device.api.system.ControlledAccessException;
import net.rim.device.api.ui.UiApplication;

import com.stepan.kutaj.APP.util.*;
import com.stepan.kutaj.APP.screen.*;
import net.rim.blackberry.api.bbm.platform.BBMPlatformApplication;
import net.rim.blackberry.api.bbm.platform.BBMPlatformContext;
import net.rim.blackberry.api.bbm.platform.BBMPlatformContextListener;
import net.rim.blackberry.api.bbm.platform.BBMPlatformManager;

public class APP  extends UiApplication{

        private BBMPlatformContext platformContext = null;
        private MyBBMAppPlugin myPlugin;
       
        public APP()
        {
                myPlugin = new MyBBMAppPlugin();
                invokeLater(new Runnable()
        {
          public void run()
          {
              try
              {
                                        platformContext = BBMPlatformManager.register(myPlugin);
              }
              catch (ControlledAccessException e)
              {
                // The BBM platform has been disabled
              }
              if (platformContext != null)
              {
                MyBBMPlatformContextListener platformContextListener;
                platformContextListener = new MyBBMPlatformContextListener();
                platformContext.setListener(platformContextListener);
               
              }
             
          }
        }
                );
               
                pushScreen(new SplashScreen(UiApplication.getUiApplication(), new RegistrationScreen()));
        }

        public static void main(String[] args)
        {
                APP app = new APP();
                app.enterEventDispatcher();
        }
       
       
        private class MyBBMAppPlugin extends BBMPlatformApplication
    {
        public MyBBMAppPlugin()
        {
            super( "UUID" );
        }
    }
       
    private class MyBBMPlatformContextListener extends BBMPlatformContextListener
    {
        public void accessChanged(boolean isAccessAllowed, int accessErrorCode)
        {
            if (!isAccessAllowed)
            {
                // You cannot access the BBM platform
            }
        }

        public void appInvoked(int reason, Object param)
        {
            // Code for handling different contexts for invocation
        }
    }
}

this is next screen where i don`t implement BBMPlatformContext
Code:


import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.profile.*;
import net.rim.device.api.ui.container.*;
import java.util.*;

public class RegistrationScreen extends MainScreen
{   
    public RegistrationScreen(BBMPlatformContext platformContext)
    {
        UserProfile userProfile = platformContext.getUserProfile();
       
        String displayName = userProfile.getDisplayName();
        Bitmap displayPicture = userProfile.getDisplayPicture();
        String personalMsg = userProfile.getPersonalMessage();
        int status = userProfile.getStatus();
        String statusMsg = userProfile.getStatusMessage();
    }
}

i try this and everything application end with error that i cannot access to modul
Code:

import net.rim.device.api.system.ControlledAccessException;
import net.rim.device.api.ui.UiApplication;

import com.stepan.kutaj.APP.util.*;
import com.stepan.kutaj.APP.screen.*;
import net.rim.blackberry.api.bbm.platform.BBMPlatformApplication;
import net.rim.blackberry.api.bbm.platform.BBMPlatformContext;
import net.rim.blackberry.api.bbm.platform.BBMPlatformContextListener;
import net.rim.blackberry.api.bbm.platform.BBMPlatformManager;

public class APP  extends UiApplication{

        private BBMPlatformContext platformContext = null;
        private MyBBMAppPlugin myPlugin;
       
        public APP()
        {
                myPlugin = new MyBBMAppPlugin();
                invokeLater(new Runnable()
        {
          public void run()
          {
              try
              {
                                        platformContext = BBMPlatformManager.register(myPlugin);
              }
              catch (ControlledAccessException e)
              {
                // The BBM platform has been disabled
              }
              if (platformContext != null)
              {
                MyBBMPlatformContextListener platformContextListener;
                platformContextListener = new MyBBMPlatformContextListener();
                platformContext.setListener(platformContextListener);
               
              }
             
          }
        }
                );
               
                pushScreen(new SplashScreen(UiApplication.getUiApplication(), new RegistrationScreen(platformContext)));
        }

        public static void main(String[] args)
        {
                APP app = new APP();
                app.enterEventDispatcher();
        }
       
       
        private class MyBBMAppPlugin extends BBMPlatformApplication
    {
        public MyBBMAppPlugin()
        {
            super( "UUID" );
        }
    }
       
    private class MyBBMPlatformContextListener extends BBMPlatformContextListener
    {
        public void accessChanged(boolean isAccessAllowed, int accessErrorCode)
        {
            if (!isAccessAllowed)
            {
                // You cannot access the BBM platform
            }
        }

        public void appInvoked(int reason, Object param)
        {
            // Code for handling different contexts for invocation
        }
    }
}

Thank you for help!!!

Best regards,

Stepan


All times are GMT -5. The time now is 06:40 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.