将字符串转换为 unicode 时出现 java 异常:
public static boolean sendOutgoingSms(String phoneNumber, String message,
Context context) {
try {
PendingIntent pi = PendingIntent.getActivity(context, 0,
new Intent(), 0);
SmsManager sms = SmsManager.getDefault();
message = Charset.forName("UTF-8").encode(message).toString();
sms.sendTextMessage(phoneNumber, null, message, pi, null);
return true;
} catch (Exception ex) {
Trace.e("Failed to send outgoing sms", ex);
}
return false;
}
错误:
"java.nio.ReadWriteHeapByteBuffer, status: capacity=8 position=0 limit=4"
我是否以错误的方式使用 Charset,forName?