blackberry j 2 me SMSメール送信


blackberryメール送信アプリは呼び出すことができます
javax.wireless.messaging.MessageConnection;
で行ないます.
 
私はまずデータレポートdatagramで2進数ファイルを送信する形式を試して、私のブラックベリー8800でテストして、文字化けしました.
public
SendSms() {
try
{
_dc = (DatagramConnection)Connector.open(_openString);
byte
[] data = msg.getBytes();
Datagram d = _dc.newDatagram(_dc.getMaximumLength());
d.setAddress("//" + addr);
_dc.send(d);
}
catch
( IOException e) {
}S
ystem.exit(0);
}

 
javaxに変更します.wireless.messaging.MessageConnection;を選択します.
任意の文字の送信に成功しました(中国語を含む)
 
コードは次のとおりです.
package com.kennan.contactList;

import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;

public final class Sender extends Thread {

	private MessageConnection _mc;
	private String _address;
	private String _message;

	public Sender(MessageConnection mc) {
		this._mc = mc;
		start();
	}

	public synchronized void send(String addr, String msg) {
		_address = addr;
		_message = msg;
		notify();
	}

	public synchronized void run() {
		while (true) {
			// If no client to deal, wait until one connects
			if (_message == null) {
				try {
					wait();
				} catch (InterruptedException e) {
				}
			}

			try {
				TextMessage msg;

				// Are we a sender thread for the client ? If so then there's
				// no address parameter
				if (_address == null) {
					msg = (TextMessage) _mc
							.newMessage(MessageConnection.TEXT_MESSAGE);
				} else {
					msg = (TextMessage) _mc.newMessage(
							MessageConnection.TEXT_MESSAGE, _address);
				}
				msg.setPayloadText(_message);
				_mc.send(msg);

			} catch (Exception ioe) {
				ioe.printStackTrace();
			}

			// Completed client handling, return handler to pool and
			// mark for wait
			_message = null;
		}
	}
}

 
コールコード
package com.kennan.contactList;

import java.io.IOException;

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

public class SendSMS {

	public static void sendSMS(String phoneNumber, String messageContext) {

		try {
			MessageConnection mc = (MessageConnection) Connector
					.open("sms://" + phoneNumber);
			Sender sender = new Sender(mc);
			sender.send(null, messageContext);
		} catch (IOException e) {

			e.printStackTrace();
		}
	}
}