GCM和特殊字符 [英] GCM and Special characters
本文介绍了GCM和特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
'?'
而不是'ö','ï',...
我的服务器记录的是正确的字符串,但应用程序收到'?'代替。
你认为这可能与GCM?
我的代码如下:
public static void displayMessage(Context context,Intent intent){
Bundle extras = intent.getExtras();
if(extras!= null){
String message =(String)extras.get(message);
Log.v(extras,extras.toString());
Util.generateNotification(context,message,intent);
}
}
然后记录:
10-02 22:18:23.671:V / intent(29809):Bundle [{message = {name:j?rg },
message_id = 8bb60eee-3a93-4075-b606-40495511a4da,collapse_key = do_not_collapse,from = 160085429222}]
最好的问候!
解决方案
我不这么认为GCM存在问题。尝试使用UTFEncoding作为消息。
$ b
String output = new String(name.getBytes(8859_1),utf- 8\" );
I recently changed my c2dm push aaplucation to GCM. A new problem appeared. Its now receiving '?'
instead of 'ö','ï', ...
My server logs correct Strings, but the application receives '?' insteads.
Do you think it could have something to do with GCM?
My code is the following:
public static void displayMessage(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
String message = (String) extras.get("message");
Log.v("extras", extras.toString());
Util.generateNotification(context, message, intent);
}
}
and the log is then:
10-02 22:18:23.671: V/intent(29809): Bundle[{message={"name":"j?rg"},
message_id=8bb60eee-3a93-4075-b606-40495511a4da, collapse_key=do_not_collapse, from=160085429222}]
Best regards!
解决方案
I dont think so there is problem in GCM. Try to use UTFEncoding for your message.
String output = new String(name.getBytes("8859_1"), "utf-8");
这篇关于GCM和特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文