gpt4 book ai didi

java - Android 中的希伯来语短信

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:17:20 28 4
gpt4 key购买 nike

我正在使用 Phonegap 创建旨在发送短信的插件。下面是我用来执行此操作的函数。

private void sendSMS(String phoneNumber, String message) {
// Activity currentActivity = (Activity)this.ctx;
SmsManager manager = SmsManager.getDefault();
PendingIntent sentIntent = PendingIntent.getActivity(cordova.getContext(), 0, new Intent(), 0);
manager.sendTextMessage(phoneNumber, null, message, sentIntent, null);
}

当变量“message”包含英文时,一切正常。但如果消息是希伯来语,我收到错误消息。

请参阅下面的希伯来语输入

סך הלכל מוזמן 2 פיטיםסלט פיצוצ בסי שווה ל 10.3 כמות 1סלט שווה ל 8.15 כמות 2 סך הכל חשבון 26.6 שקלים

下面是一个包含文本描述的类。我怀疑问题是unicode的问题,但我不知道如何解决。

请帮忙。

public class MenuEntry {
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public MenuEntry() {
super();
this.pid = "";
}
public String GetPriceAndDescription(int unit) {
StringBuilder result = new StringBuilder();
result.append(this.getTitle());
result.append(" שווה ל ");
result.append(this.getPrice());
result.append(" כמות ");
result.append(unit);
result.append("\n");
return result.toString();
}
public String GetPriceAndDescription() {
StringBuilder result = new StringBuilder();
result.append(this.getTitle());
result.append(" שווה ל ");
result.append(this.getPrice());
result.append("\n");
return result.toString();
}
public MenuEntry(String pid, String title, String description, double price, String categoryName) {
super();
this.pid = pid;
this.title = title;
this.description = description;
this.price = price;
this.categoryName = categoryName;
}
private String pid;
private String title;
private String description;
private double price;
private String categoryName;
}

请参阅下面的 list 文件定义,以查看目标版本。

 <uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />

最佳答案

我找到了答案。问题出在“SmsManager”类上。当消息太长时,该类抛出异常,但没有描述。

所以我需要使用 SmsManager 类的其他方法“sendMultipartTextMessage”。

private void sendSMS(String phoneNumber, String message) {

SmsManager manager = SmsManager.getDefault();

ArrayList<String> parts = manager.divideMessage(message);

manager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);

}

关于java - Android 中的希伯来语短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13542616/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com