Sending a multipart MMS in Nokia N95 8GB
Sending a multipart MMS in Nokia N95 8GB
Hey,
Here I share Nokia N95 8GB mobile trick with you, using this trick you able to sending a multipart MMS, for that just use following java code and use all the steps before that just go through it
This code will show how to send a multipart MMS message using java script. For using these utilities for that you have entered a destination address in text field then this application will automatically fetch a phone number from the address book. Then next text box you have to u enters a subject for the message. Then attach the image and enter the message it is for sent to the specified address.
Following message parameters are set by using this application.
• Destination address
• Subject of the message
• Message content with the attachment.
This is a complete example MIDlet, but the most interesting methods (methods regarding multipart message handling) are handle cmdsend(), preprMsg(), createMsgPart(), and sendMMS().
Use following java code for makes this application for your mobile
Before that you have to import following java files in your program
Quote:
java.io.IOException;
java.io.InputStream;
java.io.InterruptedIOException;
javax.microedition.io.Connector;
javax.microedition.lcdui.Command;
javax.microedition.lcdui.CommandListener;
javax.microedition.lcdui.Display;
javax.microedition.lcdui.Disp;
javax.microedition.lcdui.Form;
javax.microedition.lcdui.TextField;
javax.microedition.midlet.MIDlet;
javax.wireless.messaging.MessageCncton;
javax.wireless.messaging.MessagePart;
javax.wireless.messaging.MultipartMessage;
javax.wireless.messaging.SizeExceededException;
after importing all the java library and then copy this code in notepad and save with ".jar" extension and then install in your mobile
Quote:
public class MMSMIDlet extends MIDlet implements CommandListener {
private Command cmdsend;
private Command cmdexit;
private Form frmmain;
private TextField txtmmsadres;
private TextField txtmmsSub;
private MessageCncton cncton;
public MMSMIDlet() {
frmmain = new Form("Test MMS");
txtmmsadres = new TextField("MMS Address", null, 40,
TextField.PHONENUMBER);
frmmain.append(txtmmsadres);
txtmmsSub = new TextField("MMS Subject", null, 255,
TextField.PLAIN);
frmmain.append(txtmmsSub);
cmdsend = new Command("MMS Send", Command.ITEM, 0);
frmmain.addCommand( cmdsend);
cmdexit = new Command("Exit", Command.EXIT, 0);
frmmain.addCommand(cmdexit);
frmmain.setCommandListener(this);
}
public void activateApp() {
Display.getDisplay(this).setCurrent(frmmain);
}
public void stopApp() {
}
public void ClenApp(boolean unconditional) {
if (cncton != null) {
try {
cncton.close();
} catch (IOException ex) {
}
}
}
public void cmdacton(Command command, Disp disp) {
if (command == cmdexit) {
ClenApp(true);
notifyDestroyed();
} else if (command == cmdsend) {
handle cmdsend();
}
}
private void handle cmdsend() {
try {
cncton = (MessageCncton)Connector.open("mms://MyApp");
} catch (IOException ex) {
}
MultipartMessage message = preprMsg();
sendMMS(message);
}
private MultipartMessage preprMsg() {
MultipartMessage message = (MultipartMessage)cncton.newMessage(
MessageCncton.MULTIPART_MESSAGE);
String address = "mms://" + txtmmsadres.getString();
message.setAddress(address);
String subject = txtmmsSub.getString();
message.setSubject(subject);
String priority = "normal";
message.setHeader("X-Mms-Priority", priority);
try {
MessagePart messagePart = createMsgPart();
message.addMessagePart(messagePart);
} catch (SizeExceededException ex) {
} catch (IOException ex) {
}
return message;
}
private MessagePart createMsgPart() throws SizeExceededException,
IOException {
String imageContentID = "image01";
String imageContentLocation = "image.jpg";
String jpgMIME = "image/jpeg";
InputStream imageContent = getClass().getResourceAsStream(
imageContentLocation);
MessagePart messagePart = new MessagePart(imageContent, jpgMIME,
imageContentID, imageContentLocation, null);
return messagePart;
}
private void sendMMS(final MultipartMessage message) {
Thread messageThread = new Thread() {
public void run() {
try {
cncton.send(message);
frmmain.append("Message sent.");
} catch (InterruptedIOException ex) {
} catch (IOException ex) {
} catch (IllegalArgumentException ex) {
} catch (SecurityException ex) {
}
}
};
messageThread.start();
}
}
Re: Sending a multipart MMS in Nokia N95 8GB
Wow… this is such a great tricks, I use it and thanks a lot for sharing with us. And main thing is that this is not harmful for my mobile phone I use this and it is properly work, thanks dude and keep sharing this nice tricks with us.