1
是否可以使用級聯API以編程方式在Blackberry10上導入/導出短信/彩信?是否可以在Blackberry10上導入/導出短信/彩信?
是否可以使用級聯API以編程方式在Blackberry10上導入/導出短信/彩信?是否可以在Blackberry10上導入/導出短信/彩信?
SMS實際上使用與其他消息(如電子郵件)相同的API。關鍵的區別在於,您希望專門選擇SMS帳戶,並且您可能希望構建作爲對話的一部分。
使用BlackBerry PIM API的Message部分,嘗試這樣的事情:
MessageService messageService;
AccountService accountService;
//Get the SMS/MMS account
QList<Account> accountList = accountService.accounts(Service::Messages,"sms-mms");
AccountKey accountId = accountList.first().id();
// Create a contact to whom you want to send sms/mms. Put the right phone number in yourself
int contactKey = -1;
MessageContact recipient = MessageContact(contactKey, MessageContact::To,"5555555555", "5555555555");
//Create a conversation because sms/mms chats most of the time is a conversation
ConversationBuilder* conversationBuilder = ConversationBuilder::create();
conversationBuilder->accountId(accountId);
QList<MessageContact> participants;
participants.append(recipient);
conversationBuilder->participants(participants);
Conversation conversation = *conversationBuilder;
ConversationKey conversationId = messageService.save(accountId, conversation);
//Create a message Builder for sms/mms
MessageBuilder* messageBuilder = MessageBuilder::create(accountId);
messageBuilder->addRecipient(recipient);
// SMS API's handle body as an attachment.
QString body = "body of the sms";
messageBuilder->addAttachment(Attachment("text/plain","body.txt",body));
messageBuilder->conversationId(conversationId);
Message message;
message = *messageBuilder;
//Sending SMS/MMS
MessageKey key = messageService.send(accountId, message);
qDebug() << "+++++++ Message sent" << endl;`
感謝您的信息:) – Taras 2013-02-28 08:38:44