BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-15-2009, 07:05 PM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7130v
PIN: N/A
Carrier: n/a
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending SMS

Please Login to Remove!

I can't send sms from my program, it gives me "jvm error: 104 uncaught: throwable" error in simulator after sending the sms and tapping the back button to go back to the application.

I'm using jde 4.5.0 with 8330 simulator.



I wrote a sample program to send an sms and it's the same error, i hope someone can tell me whats wrong.



App.java:
Code:

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


public class App extends UiApplication
{
   Screen2 screen2;
   
    public static void main(String[] args)
    {
        App  app = new App();
        app.enterEventDispatcher();
    }
    public App()
    {
    	screen2 = new Screen2();
        pushScreen(screen2);
    }
 
}
Screen2.java:
Code:
import java.io.IOException;

import javax.microedition.io.Connector;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;


import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.MessageArguments;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;


final class Screen2 extends MainScreen
{

   
    public Screen2()
    {
        super(); 
        setTitle(new LabelField("Screen2"));
        try
        {
        	String number = "1234";
            MessageConnection mc = (MessageConnection)Connector.open("sms://");
            TextMessage textMessage = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE);
            textMessage.setAddress("sms://" + number);
            Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(textMessage));
        }
        Catch(Throwable e)
        {
        	Dialog.alert(e.getMessage());
        }
    }
}
stack trace is :
Code:
Thread [net_rim_bb_messaging_app(52)id=1076822016] (Suspended (exception Throwable))	
	UnreadCount$NewAndUnreadCount.modifyUnreadCount(int, boolean, boolean, boolean) line: 504	
	UnreadCountManager.internalModifyUnreadCount(int, int, boolean, boolean) line: 371	
	UnreadCountManager.internalModifyUnreadCount(int, int, boolean, boolean) line: 365	
	UnreadCountManager.modifyUnreadCount(int, int, boolean, boolean) line: 185	
	UnreadCountManager.decrementUnreadCount(int, boolean, boolean) line: 133	
	SMSModel.decrementCount(boolean, boolean) line: 848	
	SMSMessageModel(SMSModel).perform(long, Object) line: 977	
	MessageBulkMarkOldManager.markOld(Object) line: 207	
	MessageBulkMarkOldManager$Worker.run() line: 268	
	Thread.run() line: 379
the exception only happens with os 4.5.0 in os 4.2.1 everything ok.
Offline  
Old 07-15-2009, 09:08 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

First off, you should catch these Throwable exceptions - wrap your enterEventDispatcher with a try/catch block.

Secondly, you cannot test SMS on the 4.5 simulator - it's broken. Aside from the "decrement" issue above, you will also find that the messages app will try to cast the TextMessage object to an Email message object, which will throw a cast exception.

Thirdly, why are you opening a message connection here? You don't need this connection if you are asking the messages app to send the message for you.

And finally, you don't put the "sms://" in your address for the Message object - you only place the phone number there.
Offline  
Old 07-16-2009, 03:58 AM   #3 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7130v
PIN: N/A
Carrier: n/a
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm sorry for not being clear, i want to invoke the sms application using a number i pass from my program.
Actually it works fine on a 4.2.1 simulators.

So do you say it's a problem with the 4.5.0 simulator and on 4.5.0 devices it should work fine?
Offline  
Old 07-16-2009, 11:15 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

As I said, the 4.5 simulator Invoke is broken with regards to Messages.

The problem does not exist on the device.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.