Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
anta40
Posts: 224
Registered: ‎07-26-2010
My Device: Z10

Updating BBM personal message

I noticed that some apps like Foursquare or Twitter are able to set the BBM personal message.

Using the BBM Social Platform SDK, how to do that?

Now I'm dabbling through the samples, still cannot figure it out.

Please use plain text.
Developer
anta40
Posts: 224
Registered: ‎07-26-2010
My Device: Z10

Re: Updating BBM personal message

[ Edited ]

These are my codes, so far

 

package com.anta40.bbmstatusupdater;

import net.rim.blackberry.api.bbm.platform.BBMPlatformApplication;

public class BBMAppPlugin extends BBMPlatformApplication {

	public BBMAppPlugin(String arg0) {
		super(arg0);
	}

}
package com.anta40.bbmstatusupdater;

import net.rim.blackberry.api.bbm.platform.BBMPlatformContextListener;
import net.rim.device.api.ui.component.Dialog;

public class BBMAppPlatformContextListener extends BBMPlatformContextListener {

	public void accessChanged(boolean isAccessAllowed, int accessErrorCode) {
		
		if (isAccessAllowed) Dialog.inform("Access to the platform context is now allowed.");
		else Dialog.alert("Access to the platform is now disallowed because of error: "+ accessErrorCode);
	}

	public void appInvoked(int reason, Object param){
		
	}

}
package com.anta40.bbmstatusupdater;

import net.rim.blackberry.api.bbm.platform.BBMPlatformContext;
import net.rim.blackberry.api.bbm.platform.profile.Presence;
import net.rim.blackberry.api.bbm.platform.profile.UserProfile;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class SettingScreen extends MainScreen {

	private ButtonField btnOK;
	private LabelField lblStatus;
	private EditField editStatus;
	private UserProfile userProfile;
		
	public SettingScreen(BBMPlatformContext context){
		setTitle("Setting");
		userProfile = context.getUserProfile();
		
		lblStatus = new LabelField("BBM status: ", FIELD_LEFT);
		editStatus = new EditField();
		btnOK = new ButtonField("OK", FIELD_HCENTER | ButtonField.CONSUME_CLICK);
		
	}
	
	FieldChangeListener listener = new FieldChangeListener() {
		
		public void fieldChanged(Field field, int context) {
			
			if (field == btnOK){
				boolean allowed = userProfile.setStatus(Presence.STATUS_AVAILABLE, editStatus.getText());
				if (!allowed) Dialog.alert("Error: Cannot update BBM status.");
			}
			
		}
	};
}

 

package com.anta40.bbmstatusupdater;

import net.rim.blackberry.api.bbm.platform.BBMPlatformContext;
import net.rim.blackberry.api.bbm.platform.BBMPlatformManager;
import net.rim.device.api.ui.UiApplication;

public class BBMStatusUpdater extends UiApplication{

	private String UUID = "9def5d90-c39c-11e1-9b21-0800200c9a66";
	private BBMAppPlugin plugin;
	
	public BBMStatusUpdater(){
		plugin = new BBMAppPlugin(UUID);
		
		invokeLater(new Runnable() {
			
			public void run() {
				BBMPlatformContext platformContext = BBMPlatformManager.register(plugin);
				BBMAppPlatformContextListener platformContextListener = new BBMAppPlatformContextListener();
				platformContext.setListener(platformContextListener);
			
				SettingScreen settingScreen = new SettingScreen(platformContext);
				pushScreen(settingScreen);
			}
		});
		
	}
	
    public static void main(String[] args){
    	BBMStatusUpdater app = new BBMStatusUpdater();
    	app.enterEventDispatcher();
    }
}

 

 Still not working. Every time I run it, I get this:

"Access to the platform is now disallowed because of error: 9"

 

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Updating BBM personal message

Have you looked at the SDK and figured out how it does it?

Please use plain text.