bowline
asked on
SMS Midlet for Razr V3 - keep getting a SecurityException
Hi
I've kind of hacked my way through my first midlet to send an SMS and I keep getting the following error:
java.lang.SecurityExceptio n: javax.microedition.io.Conn ector.sms was denied
The phone is a Razr V3, CLDC 1.0, MIDP 2.0. The Java App Loader is unlocked so I've been transfering the app with Midway. It runs through Sun's emulator but I've had some other issues with the Motorola one, so I cannot say whether or not it's working there.
From the JAD:
<snippet>
MIDlet-1: SMS, SMS.png, SMS
MIDlet-Jar-Size: 2980
MIDlet-Jar-URL: SMS.jar
MIDlet-Name: SMS
MIDlet-Permissions-Opt: javax.microedition.io.Conn ector.sms, javax.wire less.messa ging.sms.s end,javax. wireless.m essaging.s ms.receive
MIDlet-Vendor: bowline
MIDlet-Version: 1.0
MicroEdition-Configuration : CLDC-1.0
MicroEdition-Profile: MIDP-2.0
</snippet>
The applicable source (I think):
<snippet>
import javax.microedition.lcdui.* ;
import javax.microedition.midlet. *;
import javax.microedition.io.*;
import javax.wireless.messaging.* ;
import java.util.*;
import java.io.*;
</snippet>
<snippet>
public void sendMessage(final String addr, final String msg) {
System.out.println("Messag e Start");
Thread th = new Thread() {
public void run() {
try {
MessageConnection conn = (MessageConnection)Connect or.open("s ms://+1" + addr);
TextMessage txtMsg = (TextMessage)conn.newMessa ge(Message Connection .TEXT_MESS AGE);
txtMsg.setPayloadText(msg) ;
conn.send(txtMsg);
conn.close();
System.out.println("Messag e Sent");
mForm.append("...Sent Message");
} catch (Exception e) {
System.out.println(e);
mForm.append("...ERROR - " + e);
}
}
};
th.start();
}
</snippet>
I've done some reading on the api and the implementation of it on this version of my phone, and from what I can tell JSR 120 is supported, and I should just have to deal with prompts asking me if it's okay that the app sends a message. I've gone into the permissions on the application, and there's not even an option for messaging, just data access. I feel like something is getting lost in translation - like when the application is installed, the phone does not know that it is going to try to access this api. I've tried messing around (blindly) with the different types of permissions and opt-permissions on the midlet's settings with no luck so far.
So...
1. Can I send SMS messages with a Midlet on this version of my phone?
2. Do I have to have a signed application to access the api? (this is just a personal project, so I'd rather not spend the money)
3. What am I doing wrong?
Thanks in advance for any help!
(and I can post more code if necessary, but it mostly just has a text box where you type in the phone number and press send - just enough to test right now)
I've kind of hacked my way through my first midlet to send an SMS and I keep getting the following error:
java.lang.SecurityExceptio
The phone is a Razr V3, CLDC 1.0, MIDP 2.0. The Java App Loader is unlocked so I've been transfering the app with Midway. It runs through Sun's emulator but I've had some other issues with the Motorola one, so I cannot say whether or not it's working there.
From the JAD:
<snippet>
MIDlet-1: SMS, SMS.png, SMS
MIDlet-Jar-Size: 2980
MIDlet-Jar-URL: SMS.jar
MIDlet-Name: SMS
MIDlet-Permissions-Opt: javax.microedition.io.Conn
MIDlet-Vendor: bowline
MIDlet-Version: 1.0
MicroEdition-Configuration
MicroEdition-Profile: MIDP-2.0
</snippet>
The applicable source (I think):
<snippet>
import javax.microedition.lcdui.*
import javax.microedition.midlet.
import javax.microedition.io.*;
import javax.wireless.messaging.*
import java.util.*;
import java.io.*;
</snippet>
<snippet>
public void sendMessage(final String addr, final String msg) {
System.out.println("Messag
Thread th = new Thread() {
public void run() {
try {
MessageConnection conn = (MessageConnection)Connect
TextMessage txtMsg = (TextMessage)conn.newMessa
txtMsg.setPayloadText(msg)
conn.send(txtMsg);
conn.close();
System.out.println("Messag
mForm.append("...Sent Message");
} catch (Exception e) {
System.out.println(e);
mForm.append("...ERROR - " + e);
}
}
};
th.start();
}
</snippet>
I've done some reading on the api and the implementation of it on this version of my phone, and from what I can tell JSR 120 is supported, and I should just have to deal with prompts asking me if it's okay that the app sends a message. I've gone into the permissions on the application, and there's not even an option for messaging, just data access. I feel like something is getting lost in translation - like when the application is installed, the phone does not know that it is going to try to access this api. I've tried messing around (blindly) with the different types of permissions and opt-permissions on the midlet's settings with no luck so far.
So...
1. Can I send SMS messages with a Midlet on this version of my phone?
2. Do I have to have a signed application to access the api? (this is just a personal project, so I'd rather not spend the money)
3. What am I doing wrong?
Thanks in advance for any help!
(and I can post more code if necessary, but it mostly just has a text box where you type in the phone number and press send - just enough to test right now)
ASKER
bglodde
Thanks for the reply, but I seem to be getting conflicting information from different sources. According to the documentation on the Razr V3, when dealing with unsigned/untrusted midlets, the phone will prompt the user for approval when a midlet tries to access the WMA. The only API's that are outright denied access seem to be those that deal with personal information and contact management. I've contacted Motorola support and they've told me that it works as documented but said that some carriers will put further restrictions on phones to prevent access to the API. I contacted T-Mobile (my carrier) to see if this was the case and they said that they don't do anything additional. Do you have any
So if I do have to go with the signing - is there a cheap/easy way to go through this? Especially since this is a personal project and I'm hacking my way through it - I've got no idea how the signing would work.
Thanks.
Thanks for the reply, but I seem to be getting conflicting information from different sources. According to the documentation on the Razr V3, when dealing with unsigned/untrusted midlets, the phone will prompt the user for approval when a midlet tries to access the WMA. The only API's that are outright denied access seem to be those that deal with personal information and contact management. I've contacted Motorola support and they've told me that it works as documented but said that some carriers will put further restrictions on phones to prevent access to the API. I contacted T-Mobile (my carrier) to see if this was the case and they said that they don't do anything additional. Do you have any
So if I do have to go with the signing - is there a cheap/easy way to go through this? Especially since this is a personal project and I'm hacking my way through it - I've got no idea how the signing would work.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry - I thought this was already deleted...tried to get to it a couple of weeks ago.
I'll award the points, but the solution was actually to flex the phone. T-Mobile apparently locks down access to a lot of API's - so I reloaded the phone with another carrier's package (Orange) and it worked...
I'll award the points, but the solution was actually to flex the phone. T-Mobile apparently locks down access to a lot of API's - so I reloaded the phone with another carrier's package (Orange) and it worked...
2. It has to be signed to operate on the device. No way around it. You are accessing a protected API - it's like that in JSR 120
3. Probably nothing wrong with your code.
Excerpt From JSR 120:
For sending messages, the MessageConnection object provides factory methods for creating Message objects. For receiving messages, the MessageConnection supports an event listener-based receive mechanism, in addition to a synchronous blocking receive() method. *The methods for sending and receiving messages can throw a SecurityException if the application does not have the permission to perform these operations.*