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
Highlighted
New Developer
Posts: 50
Registered: ‎03-18-2009
My Device: 8530
My Carrier: Movilnet

Problem Sending Message with Image with Blackberry messenger programaticly

Hi, I want send an Image with my App through Blackberry messenger, I saw the code in the sample TicaTacToedemo, but when I send the Image, I obtain a notification with this error message:

"you have invited contact_name to start the application called "Name_of_MyApp"

after that the contact recieved this notification message:

"You have received a file of type [MyApp], but the device does not recognize this file type "

And after that I received another message with this:
 
"The invitation has been declined"
 
This is my code, please help me, All that I want to do is send the image through de messenger contact that I choose:

 

private MenuItem sendtomessenger = new MenuItem( "Send to Messenger Contact" , 100000, 10 ) { public void run() { BlackBerryMessenger bbm = BlackBerryMessenger.getInstance(); if( bbm != null ) { MessengerContact contact = BlackBerryMessenger.getInstance().chooseContact(); if (contact != null) { MessengerSession = contact.getSession(); ApplicationDescriptor application = ApplicationDescriptor.currentApplicationDescriptor(); MessengerSession.sendRequest(new msnSetupListener(), application, null); } } else { Dialog.alert("BlackBerry Messenger not installed!!"); } } }; private final class msnSetupListener implements SessionSetupListener { public msnSetupListener() {} public void sessionRequestAccepted( net.rim.blackberry.api.blackberrymessenger.Session session ) { wakeRequestThread( session ); } public void sessionRequestDelivered( net.rim.blackberry.api.blackberrymessenger.Session session ) {} public void sessionRequestFailed( net.rim.blackberry.api.blackberrymessenger.Session session, int reason ) { wakeRequestThread( session ); } public void sessionRequestRefused( net.rim.blackberry.api.blackberrymessenger.Session session ) { wakeRequestThread( session ); } private void wakeRequestThread( net.rim.blackberry.api.blackberrymessenger.Session session ) { if( session == MessengerSession && MessengerSession != null ) { synchronized( MessengerSession ) { MessengerSession.notify(); try { RuntimeStore storemsnimage = RuntimeStore.getRuntimeStore(); Object msnobjimage = storemsnimage.get(msnimagenID); JPEGEncodedImage msnimage = (JPEGEncodedImage)msnobjimage; byte[] arraymsnimage = msnimage.getData(); BitmapField ImageField = new BitmapField(msnimage.getBitmap(),DrawStyle.HCENTER | DrawStyle.HCENTER ); MessengerSession.display("MyApp", ImageField); MessengerSession.send(new net.rim.blackberry.api.blackberrymessenger.Message( msnimagen.getMIMEType(), arraymsnimage)); } catch(ControlledAccessException e) { //handle exception } } } } }

 

Other thing is that when I use the Simulator of the Blackberry 8310, I obtain an exception "ArrayIndexOutofBounds" , what I cand do?

 

// Code for getting Thanks
if( iWasHelpful && solvedYourProblem ) {
Thanks++;
solution = true;
}
New Developer
Posts: 50
Registered: ‎03-18-2009
My Device: 8530
My Carrier: Movilnet

Re: Problem Sending Message with Image with Blackberry messenger programaticly

nobody who can help me with this?

 

I have an idea that could be the solution and is that I have to call in the application descriptor, not my current application. Should be rather the "blackberry messenger" application and trough of that I have to send the image. But I´m not sure and neither Know how call the blackberry messenger application, I imagine that is something like :

 

 

int modHandle = CodeModuleManager.getModuleHandle("net_rim_bbapi_blackberrymessenger.cod"); ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle); MessengerSession.sendRequest(new msnSetupListener(), apDes, null); //And after that when my session is open in the SetupListener //Send the image with MessengerSession.send(new net.rim.blackberry.api.blackberrymessenger.Message( msnimagen.getMIMEType(), arraymsnimage));

 

 

Please, some little help is good for me. Experts Please help me.

// Code for getting Thanks
if( iWasHelpful && solvedYourProblem ) {
Thanks++;
solution = true;
}
New Developer
Posts: 50
Registered: ‎03-18-2009
My Device: 8530
My Carrier: Movilnet

Re: Problem Sending Message with Image with Blackberry messenger programaticly

Well, I still have the issue, but now I know that isn´t appropriate call "net_rim_bbapi_blackberrymessenger.cod" from CodeModuleManager because isn´t an Application rather is a Library and I realized that I can´t put ".cod" in the String Name of the Module.

 

Also I know that the name of the Module for the blackberry messenger Application should be "net_rim_bb_qm_peer" but anyway I can´t put an Application Descriptor[] (array) in the Session request because is incompatible and for that reason I did this:

int modHandle = CodeModuleManager.getModuleHandle("net_rim_bb_qm_peer"); ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle); if ((apDes==null) || (apDes.length == 0)) { System.out.println("App descriptors are missing"); return; } String[] args = {"", "" }; ApplicationDescriptor msnAppDescriptor = new ApplicationDescriptor(apDes[0], "BlackBerry Messenger", args); MessengerSession.sendRequest(new msnSetupListener(), msnAppDescriptor, null); //And after that when my session is open in the SetupListener //Send the image with MessengerSession.send(new net.rim.blackberry.api.blackberrymessenger.Message( msnimagen.getMIMEType(), arraymsnimage));

 

 

 But the same, I still can´t send the image through the BlackBerry Messenger Application.

 

I don´t know if it´s that my questions are stupid or newbies or something or is that nobody help in this Forum Support.

 

// Code for getting Thanks
if( iWasHelpful && solvedYourProblem ) {
Thanks++;
solution = true;
}
Visitor
Posts: 1
Registered: ‎09-10-2010
My Device: Not Specified

Re: Problem Sending Message with Image with Blackberry messenger programaticly

Hi,

I want to ask u please if these sentences correct if I want to send just text message

MessengerSession.notify();

try {

                MessengerSession.display("MyApp");

 

                String msg = "hii";

                MessengerSession.send(new net.rim.blackberry.api.blackberrymessenger.Message("text", msg.getBytes()));

}

 

Please look to "text" word which the type is