07-01-2012 11:42 AM
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.
07-01-2012 01:11 PM - edited 07-01-2012 01:12 PM
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.Presen ce; import net.rim.blackberry.api.bbm.platform.profile.UserPr ofile; 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.BBMPlatformMan ager; 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(platformContextListene r); 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"
07-03-2012 09:28 PM
Have you looked at the SDK and figured out how it does it?