Sei la conversione di una stringa di byte array, utilizzando la codifica UTF-8.Quindi si crea un flusso di scrittore, con la codifica UTF-16, convertire il valore del byte della stringa, e scriverle nel flusso.Io onestamente non vedo come potrebbe funzionare.
Invece, provare questo:
String toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + name + "</wp:Text1>" +
"<wp:Text2>" + body + "</wp:Text2>" +
"<wp:Param>/Page2.xaml?NavigatedFrom=Toast Notification</wp:Param>" +
"</wp:Toast> " +
"</wp:Notification>";
// Do your stuff, initialize the headers, and so on...
OutputStreamWriter writer = new OutputStreamWriter(uc.getOutputStream(), "utf-8");
writer.write(toastMessage, 0, toastMessage.length());
uc.connect();
Se non riesci a passare una Stringa per il write
il metodo, quindi scrivere direttamente nel flusso di output:
String toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + name + "</wp:Text1>" +
"<wp:Text2>" + body + "</wp:Text2>" +
"<wp:Param>/Page2.xaml?NavigatedFrom=Toast Notification</wp:Param>" +
"</wp:Toast> " +
"</wp:Notification>";
byte[] mesg = toastMessage.getBytes("UTF-8");
uc.setDoOutput(true);
uc.setDoInput(true);
uc.getOutputStream().write(mesg, 0, mesg.length());
uc.connect();