View Single Post
Old 05-01-2012, 02:20 AM   #1
clowicek
Knows Where the Search Button Is
 
clowicek's Avatar
 
Join Date: May 2007
Location: Czech republic
Model: 9360
PIN: 286E290E
Carrier: T-MOBILE CZ
Posts: 15
Default UserProfile - Blackberry Messenger SDK

Please Login to Remove!

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
__________________
Stepan
----------------------------------------------------
Offline   Reply With Quote